本文整理汇总了Java中net.tsz.afinal.annotation.sqlite.ManyToOne类的典型用法代码示例。如果您正苦于以下问题:Java ManyToOne类的具体用法?Java ManyToOne怎么用?Java ManyToOne使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ManyToOne类属于net.tsz.afinal.annotation.sqlite包,在下文中一共展示了ManyToOne类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getColumnByField
import net.tsz.afinal.annotation.sqlite.ManyToOne; //导入依赖的package包/类
/**
* 获取某个属性对应的 表的列
* @param entity
* @param fieldName
* @return
*/
public static String getColumnByField(Field field){
Property property = field.getAnnotation(Property.class);
if(property != null && property.column().trim().length() != 0){
return property.column();
}
ManyToOne manyToOne = field.getAnnotation(ManyToOne.class);
if(manyToOne!=null && manyToOne.column().trim().length()!=0){
return manyToOne.column();
}
OneToMany oneToMany = field.getAnnotation(OneToMany.class);
if(oneToMany!=null && oneToMany.manyColumn()!=null &&oneToMany.manyColumn().trim().length()!=0){
return oneToMany.manyColumn();
}
Id id = field.getAnnotation(Id.class);
if(id!=null && id.column().trim().length()!=0)
return id.column();
return field.getName();
}
示例2: getFieldByColumnName
import net.tsz.afinal.annotation.sqlite.ManyToOne; //导入依赖的package包/类
/**
* 获取某个字段的值
* @param entity
* @param fieldName
* @return
*/
public static Field getFieldByColumnName(Class<?> clazz,String columnName){
Field field = null;
if(columnName!=null){
Field[] fields = clazz.getDeclaredFields();
if(fields!=null && fields.length>0){
if(columnName.equals(ClassUtils.getPrimaryKeyColumn(clazz)))
field = ClassUtils.getPrimaryKeyField(clazz);
if(field == null){
for(Field f : fields){
Property property = f.getAnnotation(Property.class);
if(property!=null && columnName.equals(property.column())){
field = f;
break;
}
ManyToOne manyToOne = f.getAnnotation(ManyToOne.class);
if(manyToOne!=null && manyToOne.column().trim().length()!=0){
field = f;
break;
}
}
}
if(field == null){
field = getFieldByName(clazz, columnName);
}
}
}
return field;
}
示例3: isManyToOne
import net.tsz.afinal.annotation.sqlite.ManyToOne; //导入依赖的package包/类
public static boolean isManyToOne(Field field){
return field.getAnnotation(ManyToOne.class)!=null;
}