private String getMappedBy(MetaAttribute attr) {
ManyToMany manyManyAnnotation = attr.getAnnotation(ManyToMany.class);
OnetoMany oneManyAnnotation = attr.getAnnotation(OnetoMany.class);
OnetoOne oneOneAnnotation = attr.getAnnotation(OnetoOne.class);
String mappedBy = null;
if (manyManyAnnotation != null) {
mappedBy = manyManyAnnotation.mappedBy();
}
if (oneManyAnnotation != null) {
mappedBy = oneManyAnnotation.mappedBy();
}
if (oneOneAnnotation != null) {
mappedBy = oneOneAnnotation.mappedBy();
}
if (mappedBy != null && mappedBy.length() == 0) {
mappedBy = null;
}
return mappedBy;
}
@Override
public Optional<ResourceFieldType> getFieldType(BeanAttribute@R_864_4045@ion attributeDesc) {
Optional<OnetoOne> onetoOne = attributeDesc.getAnnotation(OnetoOne.class);
Optional<OnetoMany> onetoMany = attributeDesc.getAnnotation(OnetoMany.class);
Optional<ManyToOne> manyToOne = attributeDesc.getAnnotation(ManyToOne.class);
Optional<ManyToMany> manyToMany = attributeDesc.getAnnotation(ManyToMany.class);
if (onetoOne.isPresent() || onetoMany.isPresent() || manyToOne.isPresent() || manyToMany.isPresent()) {
return Optional.of(ResourceFieldType.RELATIONSHIP);
}
Optional<Id> id = attributeDesc.getAnnotation(Id.class);
Optional<EmbeddedId> embeddedId = attributeDesc.getAnnotation(EmbeddedId.class);
if (id.isPresent() || embeddedId.isPresent()) {
return Optional.of(ResourceFieldType.ID);
}
return Optional.empty();
}
@Override
public Optional<SerializeType> getSerializeType(BeanAttribute@R_864_4045@ion attributeDesc) {
Optional<OnetoMany> onetoMany = attributeDesc.getAnnotation(OnetoMany.class);
if (onetoMany.isPresent()) {
return toSerializeType(onetoMany.get().fetch());
}
Optional<ManyToOne> manyToOne = attributeDesc.getAnnotation(ManyToOne.class);
if (manyToOne.isPresent()) {
return toSerializeType(manyToOne.get().fetch());
}
Optional<ManyToMany> manyToMany = attributeDesc.getAnnotation(ManyToMany.class);
if (manyToMany.isPresent()) {
return toSerializeType(manyToMany.get().fetch());
}
Optional<ElementCollection> elementCollection = attributeDesc.getAnnotation(ElementCollection.class);
if (elementCollection.isPresent()) {
return toSerializeType(elementCollection.get().fetch());
}
return Optional.empty();
}
项目:lemon
文件:PlmIssue.java
/** @return . */
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "PLM_ISSUE_VERSION",joinColumns = { @JoinColumn(name = "ISSUE_ID",nullable = false,updatable = false) },inverseJoinColumns = { @JoinColumn(name = "VERSION_ID",updatable = false) })
public Set<PlmVersion> getPlmVersions() {
return this.plmVersions;
}
项目:lams
文件:AnnotationBinder.java
private static boolean hasAnnotationsOnIdClass(XClass idClass) {
// if(idClass.getAnnotation(Embeddable.class) != null)
// return true;
List<XProperty> properties = idClass.getDeclaredProperties( XClass.ACCESS_FIELD );
for ( XProperty property : properties ) {
if ( property.isAnnotationPresent( Column.class ) || property.isAnnotationPresent( OnetoMany.class ) ||
property.isAnnotationPresent( ManyToOne.class ) || property.isAnnotationPresent( Id.class ) ||
property.isAnnotationPresent( GeneratedValue.class ) || property.isAnnotationPresent( OnetoOne.class ) ||
property.isAnnotationPresent( ManyToMany.class )
) {
return true;
}
}
List<XMethod> methods = idClass.getDeclaredMethods();
for ( XMethod method : methods ) {
if ( method.isAnnotationPresent( Column.class ) || method.isAnnotationPresent( OnetoMany.class ) ||
method.isAnnotationPresent( ManyToOne.class ) || method.isAnnotationPresent( Id.class ) ||
method.isAnnotationPresent( GeneratedValue.class ) || method.isAnnotationPresent( OnetoOne.class ) ||
method.isAnnotationPresent( ManyToMany.class )
) {
return true;
}
}
return false;
}
项目:infiniquery-core
文件:DefaultQueryModelService.java
/**
*
* Append the entity attribute name to the JPQL query statement.
*
* @param jpqlStatement
* @param jpaEntity
* @param attribute
* @throws java.lang.SecurityException
* @throws NoSuchFieldException
* @throws ClassNotFoundException
*/
private void appendEntityAttributeName(StringBuilder jpqlStatement,JpaEntity jpaEntity,EntityAttribute attribute,AtomicInteger aliasUnicityKey,AtomicInteger joinAdditionsOffset) throws NoSuchFieldException,java.lang.SecurityException,ClassNotFoundException {
Class<?> entityClass = Class.forName(jpaEntity.getClassName());
Field field = entityClass.getDeclaredField(attribute.getAttributeName());
boolean isJointRelationship =
field.getAnnotation(OnetoOne.class) != null
|| field.getAnnotation(OnetoMany.class) != null
|| field.getAnnotation(ManyToOne.class) != null
|| field.getAnnotation(ManyToMany.class) != null;
if(isJointRelationship) {
StringBuilder joinFragment = new StringBuilder();
Queue<String> objectTreePath = extractDotSeparatedpathFragments(attribute.getPossibleValueLabelAttributePath());
completeJoinFragment(joinFragment,entityClass,objectTreePath,aliasUnicityKey);
jpqlStatement.insert(joinAdditionsOffset.get(),joinFragment);
joinAdditionsOffset.set(joinAdditionsOffset.get() + joinFragment.length());
jpqlStatement.append(" x").append(aliasUnicityKey.get()).append('.').append(attribute.getPossibleValueLabelAttribute());
} else {
jpqlStatement.append(" x.").append(attribute.getAttributeName());
}
}
private String getMappedBy(MetaAttribute attr) {
ManyToMany manyManyAnnotation = attr.getAnnotation(ManyToMany.class);
OnetoMany oneManyAnnotation = attr.getAnnotation(OnetoMany.class);
OnetoOne oneOneAnnotation = attr.getAnnotation(OnetoOne.class);
String mappedBy = null;
if (manyManyAnnotation != null) {
mappedBy = manyManyAnnotation.mappedBy();
}
if (oneManyAnnotation != null) {
mappedBy = oneManyAnnotation.mappedBy();
}
if (oneOneAnnotation != null) {
mappedBy = oneOneAnnotation.mappedBy();
}
if (mappedBy != null && mappedBy.length() == 0) {
mappedBy = null;
}
return mappedBy;
}
protected FieldInfo buildFieldInfo(Field field) {
FieldInfo info = new FieldInfo();
info.setName(field.getName());
info.setGenericType(field.getGenericType());
ManyToMany manyToMany = field.getAnnotation(ManyToMany.class);
if (manyToMany != null) {
info.setManyToManyMappedBy(manyToMany.mappedBy());
info.setManyToManyTargetEntity(manyToMany.targetEntity().getName());
}
OnetoMany onetoMany = field.getAnnotation(OnetoMany.class);
if (onetoMany != null) {
info.setonetoManyMappedBy(onetoMany.mappedBy());
info.setonetoManyTargetEntity(onetoMany.targetEntity().getName());
}
MapKey mapKey = field.getAnnotation(MapKey.class);
if (mapKey != null) {
info.setMapKey(mapKey.name());
}
return info;
}
protected FieldInfo buildFieldInfo(Field field) {
FieldInfo info = new FieldInfo();
info.setName(field.getName());
info.setGenericType(field.getGenericType());
ManyToMany manyToMany = field.getAnnotation(ManyToMany.class);
if (manyToMany != null) {
info.setManyToManyMappedBy(manyToMany.mappedBy());
info.setManyToManyTargetEntity(manyToMany.targetEntity().getName());
}
OnetoMany onetoMany = field.getAnnotation(OnetoMany.class);
if (onetoMany != null) {
info.setonetoManyMappedBy(onetoMany.mappedBy());
info.setonetoManyTargetEntity(onetoMany.targetEntity().getName());
}
return info;
}
protected FieldInfo buildFieldInfo(Field field) {
FieldInfo info = new FieldInfo();
info.setName(field.getName());
info.setGenericType(field.getGenericType());
ManyToMany manyToMany = field.getAnnotation(ManyToMany.class);
if (manyToMany != null) {
info.setManyToManyMappedBy(manyToMany.mappedBy());
info.setManyToManyTargetEntity(manyToMany.targetEntity().getName());
}
OnetoMany onetoMany = field.getAnnotation(OnetoMany.class);
if (onetoMany != null) {
info.setonetoManyMappedBy(onetoMany.mappedBy());
info.setonetoManyTargetEntity(onetoMany.targetEntity().getName());
}
MapKey mapKey = field.getAnnotation(MapKey.class);
if (mapKey != null) {
info.setMapKey(mapKey.name());
}
return info;
}
项目:SparkCommerce
文件:AbstractFieldPersistenceProvider.java
protected FieldInfo buildFieldInfo(Field field) {
FieldInfo info = new FieldInfo();
info.setName(field.getName());
info.setGenericType(field.getGenericType());
ManyToMany manyToMany = field.getAnnotation(ManyToMany.class);
if (manyToMany != null) {
info.setManyToManyMappedBy(manyToMany.mappedBy());
info.setManyToManyTargetEntity(manyToMany.targetEntity().getName());
}
OnetoMany onetoMany = field.getAnnotation(OnetoMany.class);
if (onetoMany != null) {
info.setonetoManyMappedBy(onetoMany.mappedBy());
info.setonetoManyTargetEntity(onetoMany.targetEntity().getName());
}
return info;
}
protected FieldInfo buildFieldInfo(Field field) {
FieldInfo info = new FieldInfo();
info.setName(field.getName());
info.setGenericType(field.getGenericType());
ManyToMany manyToMany = field.getAnnotation(ManyToMany.class);
if (manyToMany != null) {
info.setManyToManyMappedBy(manyToMany.mappedBy());
info.setManyToManyTargetEntity(manyToMany.targetEntity().getName());
}
OnetoMany onetoMany = field.getAnnotation(OnetoMany.class);
if (onetoMany != null) {
info.setonetoManyMappedBy(onetoMany.mappedBy());
info.setonetoManyTargetEntity(onetoMany.targetEntity().getName());
}
MapKey mapKey = field.getAnnotation(MapKey.class);
if (mapKey != null) {
info.setMapKey(mapKey.name());
}
return info;
}
项目:hql-builder
文件:EntityRelationHelper.java
private Annotation mappedByAnything(String property) {
Field field = findField(property);
Annotation relationAnnotation = null;
relationAnnotation = field.getAnnotation(ManyToMany.class);
if (relationAnnotation != null) {
return relationAnnotation;
}
relationAnnotation = field.getAnnotation(OnetoOne.class);
if (relationAnnotation != null) {
return relationAnnotation;
}
relationAnnotation = field.getAnnotation(OnetoMany.class);
if (relationAnnotation != null) {
return relationAnnotation;
}
relationAnnotation = field.getAnnotation(ManyToOne.class);
if (relationAnnotation != null) {
return relationAnnotation;
}
return null;
}
项目:elide
文件:Parent.java
@ReadPermission(expression = "allow all OR deny all")
@UpdatePermission(expression = "allow all OR deny all")
// Hibernate
@ManyToMany(
targetEntity = Child.class,cascade = { CascadeType.PERSIST,CascadeType.MERGE }
)
@JoinTable(
name = "Parent_Child",joinColumns = @JoinColumn(name = "parent_id"),inverseJoinColumns = @JoinColumn(name = "child_id")
)
@NotNull
public Set<Child> getChildren() {
return children;
}
项目:hql-builder
文件:EntityRelationHelper.java
private Annotation anyAnnotation(Field field) {
Annotation annotation = null;
annotation = field.getAnnotation(ManyToMany.class);
if (annotation != null) {
return annotation;
}
annotation = field.getAnnotation(OnetoOne.class);
if (annotation != null) {
return annotation;
}
annotation = field.getAnnotation(OnetoMany.class);
if (annotation != null) {
return annotation;
}
annotation = field.getAnnotation(ManyToOne.class);
if (annotation != null) {
return annotation;
}
return null;
}
项目:hql-builder
文件:EntityRelationHelper.java
private Class<?> targetEntity(Annotation relationAnnotation) {
if (relationAnnotation instanceof ManyToMany) {
return ManyToMany.class.cast(relationAnnotation).targetEntity();
}
if (relationAnnotation instanceof OnetoOne) {
return OnetoOne.class.cast(relationAnnotation).targetEntity();
}
if (relationAnnotation instanceof OnetoMany) {
return OnetoMany.class.cast(relationAnnotation).targetEntity();
}
if (relationAnnotation instanceof ManyToOne) {
return ManyToOne.class.cast(relationAnnotation).targetEntity();
}
return null;
}
项目:blcdemo
文件:AbstractFieldPersistenceProvider.java
protected FieldInfo buildFieldInfo(Field field) {
FieldInfo info = new FieldInfo();
info.setName(field.getName());
info.setGenericType(field.getGenericType());
ManyToMany manyToMany = field.getAnnotation(ManyToMany.class);
if (manyToMany != null) {
info.setManyToManyMappedBy(manyToMany.mappedBy());
info.setManyToManyTargetEntity(manyToMany.targetEntity().getName());
}
OnetoMany onetoMany = field.getAnnotation(OnetoMany.class);
if (onetoMany != null) {
info.setonetoManyMappedBy(onetoMany.mappedBy());
info.setonetoManyTargetEntity(onetoMany.targetEntity().getName());
}
return info;
}
项目:oscm
文件:ReflectiveClone.java
private static boolean needsToCascade(Field field) {
Class<?> fieldtype = field.getType();
if (!DomainObject.class.isAssignableFrom(fieldtype))
return false;
Annotation ann;
CascadeType[] cascades = null;
ann = field.getAnnotation(OnetoOne.class);
if (ann != null) {
cascades = ((OnetoOne) ann).cascade();
} else {
ann = field.getAnnotation(OnetoMany.class);
if (ann != null) {
cascades = ((OnetoMany) ann).cascade();
} else {
ann = field.getAnnotation(ManyToOne.class);
if (ann != null) {
cascades = ((ManyToOne) ann).cascade();
} else {
ann = field.getAnnotation(ManyToMany.class);
if (ann != null) {
cascades = ((ManyToMany) ann).cascade();
}
}
}
}
if (cascades == null)
return false;
for (CascadeType cas : cascades) {
if ((cas == CascadeType.ALL) || (cas == CascadeType.MERGE)
|| (cas == CascadeType.PERSIST)
|| (cas == CascadeType.REMOVE)) {
return true;
}
}
return false;
}
@Override
public Optional<String> getoppositeName(BeanAttribute@R_864_4045@ion attributeDesc) {
Optional<OnetoMany> onetoMany = attributeDesc.getAnnotation(OnetoMany.class);
if (onetoMany.isPresent()) {
return Optional.ofNullable(StringUtils.emptyToNull(onetoMany.get().mappedBy()));
}
Optional<ManyToMany> manyToMany = attributeDesc.getAnnotation(ManyToMany.class);
if (manyToMany.isPresent()) {
return Optional.ofNullable(StringUtils.emptyToNull(manyToMany.get().mappedBy()));
}
return Optional.empty();
}
项目:Equella
文件:Property.java
public boolean isManyToMany()
{
if( isManyToMany == null )
{
isManyToMany = getAnnotation(ManyToMany.class) != null;
}
return isManyToMany;
}
项目:lams
文件:PropertyContainer.java
private static boolean discoverTypeWithoutReflection(XProperty p) {
if ( p.isAnnotationPresent( OnetoOne.class ) && !p.getAnnotation( OnetoOne.class )
.targetEntity()
.equals( void.class ) ) {
return true;
}
else if ( p.isAnnotationPresent( OnetoMany.class ) && !p.getAnnotation( OnetoMany.class )
.targetEntity()
.equals( void.class ) ) {
return true;
}
else if ( p.isAnnotationPresent( ManyToOne.class ) && !p.getAnnotation( ManyToOne.class )
.targetEntity()
.equals( void.class ) ) {
return true;
}
else if ( p.isAnnotationPresent( ManyToMany.class ) && !p.getAnnotation( ManyToMany.class )
.targetEntity()
.equals( void.class ) ) {
return true;
}
else if ( p.isAnnotationPresent( org.hibernate.annotations.Any.class ) ) {
return true;
}
else if ( p.isAnnotationPresent( ManyToAny.class ) ) {
if ( !p.isCollection() && !p.isArray() ) {
throw new AnnotationException( "@ManyToAny used on a non collection non array property: " + p.getName() );
}
return true;
}
else if ( p.isAnnotationPresent( Type.class ) ) {
return true;
}
else if ( p.isAnnotationPresent( Target.class ) ) {
return true;
}
return false;
}
项目:lams
文件:EnhancementTask.java
@Override
public boolean isMappedCollection(CtField field) {
try {
return (field.getAnnotation(OnetoMany.class) != null ||
field.getAnnotation(ManyToMany.class) != null ||
field.getAnnotation(ElementCollection.class) != null);
}
catch (ClassNotFoundException e) {
return false;
}
}
项目:aws-photosharing-example
文件:User.java
@XmlTransient
@LazyCollection(LazyCollectionoption.EXTRA)
@ManyToMany(fetch=FetchType.LAZY,cascade=CascadeType.ALL)
@JoinTable(name = "role_mappings",joinColumns = {
@JoinColumn(name = "user_id",inverseJoinColumns = { @JoinColumn(name = "role",updatable = false) })
public List<Role> getRoles() {return _roles;}
项目:aws-photosharing-example
文件:Media.java
@ManyToMany(fetch=FetchType.LAZY,cascade=CascadeType.PERSIST)
@JoinTable(name = "album_media",joinColumns = {
@JoinColumn(name = "media_id",inverseJoinColumns = {
@JoinColumn(name = "album_id",updatable = false) })
public List<Album> getAlbums() {return albums;}
项目:tianti
文件:User.java
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "org_user_role_rel",joinColumns = {@JoinColumn(name = "user_id")},inverseJoinColumns = {@JoinColumn(name = "role_id")})
@Where(clause="delete_flag=0")
@OrderBy("no")
public Set<Role> getRoles() {
return roles;
}
项目:tianti
文件:Role.java
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "org_role_resource_rel",joinColumns = {@JoinColumn(name = "role_id")},inverseJoinColumns = {@JoinColumn(name = "resources_id")})
public Set<Resource> getResources() {
return resources;
}
项目:tap17-muggl-javaee
文件:Team.java
@ManyToMany
@JoinTable(
name="PERSISTENCE_ROSTER_TEAM_PLAYER",joinColumns=
@JoinColumn(name="TEAM_ID",referencedColumnName="ID"),inverseJoinColumns=
@JoinColumn(name="PLAYER_ID",referencedColumnName="ID")
)
public Collection<Player> getPlayers() {
return players;
}
项目:QRcode-factory
文件:UserTest.java
@Test
public void roles() {
ManyToMany manyToMany = ReflectTool.getmethodAnnotation(User.class,"getRoles",ManyToMany.class);
Assert.assertEquals("",manyToMany.mappedBy());
Assert.assertEquals(FetchType.LAZY,manyToMany.fetch());
JoinTable joinTable = ReflectTool.getmethodAnnotation(User.class,JoinTable.class);
Assert.assertEquals("user_role",joinTable.name());
Assert.assertEquals("users_id",joinTable.joinColumns()[0].name());
Assert.assertEquals("role_id",joinTable.inverseJoinColumns()[0].name());
}
项目:jkes
文件:EventSupport.java
private CascadeType[] getCascadeTypes(AccessibleObject accessibleObject) {
CascadeType[] cascadeTypes = null;
if(accessibleObject.isAnnotationPresent(OnetoMany.class)) {
cascadeTypes = accessibleObject.getAnnotation(OnetoMany.class).cascade();
}else if(accessibleObject.isAnnotationPresent(ManyToOne.class)) {
cascadeTypes = accessibleObject.getAnnotation(ManyToOne.class).cascade();
}else if(accessibleObject.isAnnotationPresent(ManyToMany.class)) {
cascadeTypes = accessibleObject.getAnnotation(ManyToMany.class).cascade();
}
return cascadeTypes;
}
项目:lj-projectbuilder
文件:CodeTemplateEntity.java
@ManyToMany
@JoinTable(name="CODETEMPLATE_PROJECT",joinColumns=
@JoinColumn(name="CODETEMPLATE_ID",inverseJoinColumns=
@JoinColumn(name="PROJECT_ID",referencedColumnName="ID")
)
public Set<ProjectEntity> getProjects() {
return projects;
}
项目:helium
文件:Usuari.java
@ManyToMany(fetch=FetchType.EAGER)
@JoinTable(
name="hel_usuari_permis",joinColumns=
@JoinColumn(name="codi",referencedColumnName="codi"),inverseJoinColumns=
@JoinColumn(name="permis",referencedColumnName="codi")
)
@ForeignKey(name="hel_permis_usuari_fk",inverseName="hel_usuari_permis_fk")
public Set<Permis> getPermisos() {
return this.permisos;
}
项目:webpedidos
文件:Usuario.java
@ManyToMany(cascade = CascadeType.REFRESH,fetch = FetchType.LAZY)
@JoinTable(name = "usuario_grupo",joinColumns = {
@JoinColumn(name = "usuario_id",foreignKey = @ForeignKey(name = "fk_usuario_grupo_to_usuario")
) },inverseJoinColumns = { @JoinColumn(name = "grupo_id",foreignKey = @ForeignKey(name = "fk_usuario_grupo_to_grupo")) })
public Set<Grupo> getGrupos() {
return grupos;
}
项目:my-paper
文件:Member.java
/**
* 获取收藏商品
*
* @return 收藏商品
*/
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "xx_member_favorite_product")
@OrderBy("createDate desc")
public Set<Product> getFavoriteProducts() {
return favoriteProducts;
}
项目:my-paper
文件:ProductCategory.java
/**
* 获取筛选品牌
*
* @return 筛选品牌
*/
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "xx_product_category_brand")
@OrderBy("order asc")
public Set<Brand> getBrands() {
return brands;
}
项目:my-paper
文件:PaymentMethod.java
项目:my-paper
文件:Admin.java
/**
* 获取角色
*
* @return 角色
*/
@NotEmpty
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(name = "xx_admin_role")
public Set<Role> getRoles() {
return roles;
}
项目:my-paper
文件:Article.java
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。