本文整理汇总了Java中com.datastax.driver.mapping.annotations.Table类的典型用法代码示例。如果您正苦于以下问题:Java Table类的具体用法?Java Table怎么用?Java Table使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Table类属于com.datastax.driver.mapping.annotations包,在下文中一共展示了Table类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: oneTimeTearDown
import com.datastax.driver.mapping.annotations.Table; //导入依赖的package包/类
@AfterClass
public static void oneTimeTearDown() throws UnknownHostException {
long start = System.currentTimeMillis();
while ((System.currentTimeMillis() - start) < 3000)
;
Session session = getSession();
Set<Class<? extends SensorData>> sensorDataClasses = new Reflections(
"de.tudarmstadt.informatik.tk.assistanceplatform.data")
.getSubTypesOf(SensorData.class);
for (Class<? extends SensorData> c : sensorDataClasses) {
for (int i = 0; i < 100; i++) {
session.execute("DELETE FROM "
+ c.getAnnotation(Table.class).name()
+ " WHERE user_id = 0 AND device_id = 0");
}
}
}
示例2: getEntityMapperForClass
import com.datastax.driver.mapping.annotations.Table; //导入依赖的package包/类
/**
* Factory method: found instance of <code>CassandraEntityMapper</code> from <code>mappers</code>
* by <code>clazz</code> or create instance if not found and return it.
*
* @param clazz using for searching instance of <code>CassandraEntityMapper</code> in
* <code>mappers</code>
* @param cassandraClient using when creating new instance of CassandraEntityMapper
*/
@SuppressWarnings("unchecked")
public static <E> CassandraEntityMapper<E> getEntityMapperForClass(
Class<E> clazz,
CassandraClient cassandraClient
) {
CassandraEntityMapper<?> mapper = mappers.get(clazz);
if (mapper == null) {
if (clazz.isAnnotationPresent(Table.class)) {
cassandraClient.getMapper(clazz);
}
mapper = new CassandraEntityMapper<E>(clazz, cassandraClient);
mappers.put(clazz, mapper);
}
return (CassandraEntityMapper<E>) mapper;
}
示例3: postProcessBeanFactory
import com.datastax.driver.mapping.annotations.Table; //导入依赖的package包/类
@SuppressWarnings("unused") // compiler bug?
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory context) throws BeansException {
synchronized (lock) {
ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(
false);
scanner.addIncludeFilter(new AnnotationTypeFilter(Table.class));
for (BeanDefinition bd : scanner.findCandidateComponents(basePackage)) {
Class<?> entityCls;
try {
entityCls = Class.forName(bd.getBeanClassName());
} catch (ClassNotFoundException e) {
throw new AssertionError(e);
}
log.info("Creating proxy mapper for entity: " + entityCls.getName());
CassandraMapper annotation = entityCls.getAnnotation(CassandraMapper.class);
Mapper<?> bean = createProxy(Mapper.class, new MyInterceptor(entityCls, annotation.singleton()));
String beanName;
if (annotation == null)
beanName = StringUtils.uncapitalize(entityCls.getSimpleName()) + "Mapper";
else
beanName = annotation.value();
context.registerSingleton(beanName, bean);
log.info("Bean registed, name=" + beanName + ", bean=" + bean.toString());
}
}
}
示例4: extractSchemaName
import com.datastax.driver.mapping.annotations.Table; //导入依赖的package包/类
private static String extractSchemaName(Class<?> c) {
Table tableAnnotation = c.getAnnotation(Table.class);
UDT udtAnnotation = c.getAnnotation(UDT.class);
if (tableAnnotation != null) {
return tableAnnotation.name();
} else if (udtAnnotation != null) {
return udtAnnotation.name();
}
return null;
}
示例5: getTableAnnotation
import com.datastax.driver.mapping.annotations.Table; //导入依赖的package包/类
/**
* Add Table annotation to class.
*/
private static AnnotationSpec getTableAnnotation(String keyspace, String name) {
return AnnotationSpec.builder(Table.class).addMember("keyspace", "$S", keyspace)
.addMember("name", "$S", name).build();
}