javax.persistence.JoinTable Java Examples
The following examples show how to use
javax.persistence.JoinTable.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JPAOverriddenAnnotationReader.java From lams with GNU General Public License v2.0 | 6 votes |
private List<AssociationOverride> buildAssociationOverrides(Element element, XMLContext.Default defaults) { List<Element> subelements = element == null ? null : element.elements( "association-override" ); List<AssociationOverride> overrides = new ArrayList<>(); if ( subelements != null && subelements.size() > 0 ) { for ( Element current : subelements ) { AnnotationDescriptor override = new AnnotationDescriptor( AssociationOverride.class ); copyStringAttribute( override, current, "name", true ); override.setValue( "joinColumns", getJoinColumns( current, false ) ); JoinTable joinTable = buildJoinTable( current, defaults ); if ( joinTable != null ) { override.setValue( "joinTable", joinTable ); } overrides.add( AnnotationFactory.create( override ) ); } } return overrides; }
Example #2
Source File: JPAOverriddenAnnotationReader.java From lams with GNU General Public License v2.0 | 6 votes |
private JoinTable buildJoinTable(Element tree, XMLContext.Default defaults) { Element subelement = tree == null ? null : tree.element( "join-table" ); final Class<JoinTable> annotationType = JoinTable.class; if ( subelement == null ) { return null; } //ignore java annotation, an element is defined AnnotationDescriptor annotation = new AnnotationDescriptor( annotationType ); copyStringAttribute( annotation, subelement, "name", false ); copyStringAttribute( annotation, subelement, "catalog", false ); if ( StringHelper.isNotEmpty( defaults.getCatalog() ) && StringHelper.isEmpty( (String) annotation.valueOf( "catalog" ) ) ) { annotation.setValue( "catalog", defaults.getCatalog() ); } copyStringAttribute( annotation, subelement, "schema", false ); if ( StringHelper.isNotEmpty( defaults.getSchema() ) && StringHelper.isEmpty( (String) annotation.valueOf( "schema" ) ) ) { annotation.setValue( "schema", defaults.getSchema() ); } buildUniqueConstraints( annotation, subelement ); buildIndex( annotation, subelement ); annotation.setValue( "joinColumns", getJoinColumns( subelement, false ) ); annotation.setValue( "inverseJoinColumns", getJoinColumns( subelement, true ) ); return AnnotationFactory.create( annotation ); }
Example #3
Source File: AbstractPropertyHolder.java From lams with GNU General Public License v2.0 | 6 votes |
private static Map<String, JoinTable> buildJoinTableOverride(XAnnotatedElement element, String path) { Map<String, JoinTable> tableOverride = new HashMap<String, JoinTable>(); if ( element != null ) { AssociationOverride[] overrides = buildAssociationOverrides( element, path ); if ( overrides != null ) { for ( AssociationOverride depAttr : overrides ) { if ( depAttr.joinColumns().length == 0 ) { tableOverride.put( StringHelper.qualify( path, depAttr.name() ), depAttr.joinTable() ); } } } } return tableOverride; }
Example #4
Source File: AbstractPropertyHolder.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Get column overriding, property first, then parent, then holder * replace the placeholder 'collection&&element' with nothing * * These rules are here to support both JPA 2 and legacy overriding rules. */ public JoinTable getOverriddenJoinTable(String propertyName) { JoinTable result = getExactOverriddenJoinTable( propertyName ); if ( result == null && propertyName.contains( ".collection&&element." ) ) { //support for non map collections where no prefix is needed //TODO cache the underlying regexp result = getExactOverriddenJoinTable( propertyName.replace( ".collection&&element.", "." ) ); } return result; }
Example #5
Source File: User.java From ankush with GNU Lesser General Public License v3.0 | 5 votes |
/** * Gets the roles. * * @return the roles */ @ManyToMany(fetch = FetchType.EAGER) @JoinTable(name = "user_role", joinColumns = { @JoinColumn(name = "user_id") }, inverseJoinColumns = @JoinColumn(name = "role_id")) @JsonIgnore public Set<Role> getRoles() { return roles; }
Example #6
Source File: User.java From MiniWeChat-Server with MIT License | 5 votes |
@ManyToMany(targetEntity=User.class) @JoinTable(name = "user_friends", joinColumns = @JoinColumn(name = "user_id"), inverseJoinColumns = @JoinColumn(name = "friend_id")) public List<User> getFriends() { return friends; }
Example #7
Source File: Contact.java From resteasy-examples with Apache License 2.0 | 5 votes |
@ManyToMany(cascade = {CascadeType.ALL}, fetch = FetchType.EAGER) @JoinTable(name = "ContactToContactJoinTable", joinColumns = @JoinColumn(name = "parentContactId"), inverseJoinColumns = @JoinColumn(name = "childContactId")) @XmlTransient public Set<Contact> getContactChildren() { return contactChildren; }
Example #8
Source File: Role.java From tianti with Apache License 2.0 | 5 votes |
@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; }
Example #9
Source File: User.java From tianti with Apache License 2.0 | 5 votes |
@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; }
Example #10
Source File: AbstractPropertyHolder.java From lams with GNU General Public License v2.0 | 5 votes |
private void buildHierarchyColumnOverride(XClass element) { XClass current = element; Map<String, Column[]> columnOverride = new HashMap<String, Column[]>(); Map<String, JoinColumn[]> joinColumnOverride = new HashMap<String, JoinColumn[]>(); Map<String, JoinTable> joinTableOverride = new HashMap<String, JoinTable>(); Map<String, ForeignKey> foreignKeyOverride = new HashMap<String, ForeignKey>(); while ( current != null && !context.getBootstrapContext().getReflectionManager().toXClass( Object.class ).equals( current ) ) { if ( current.isAnnotationPresent( Entity.class ) || current.isAnnotationPresent( MappedSuperclass.class ) || current.isAnnotationPresent( Embeddable.class ) ) { //FIXME is embeddable override? Map<String, Column[]> currentOverride = buildColumnOverride( current, getPath() ); Map<String, JoinColumn[]> currentJoinOverride = buildJoinColumnOverride( current, getPath() ); Map<String, JoinTable> currentJoinTableOverride = buildJoinTableOverride( current, getPath() ); Map<String, ForeignKey> currentForeignKeyOverride = buildForeignKeyOverride( current, getPath() ); currentOverride.putAll( columnOverride ); //subclasses have precedence over superclasses currentJoinOverride.putAll( joinColumnOverride ); //subclasses have precedence over superclasses currentJoinTableOverride.putAll( joinTableOverride ); //subclasses have precedence over superclasses currentForeignKeyOverride.putAll( foreignKeyOverride ); //subclasses have precedence over superclasses columnOverride = currentOverride; joinColumnOverride = currentJoinOverride; joinTableOverride = currentJoinTableOverride; foreignKeyOverride = currentForeignKeyOverride; } current = current.getSuperclass(); } holderColumnOverride = columnOverride.size() > 0 ? columnOverride : null; holderJoinColumnOverride = joinColumnOverride.size() > 0 ? joinColumnOverride : null; holderJoinTableOverride = joinTableOverride.size() > 0 ? joinTableOverride : null; holderForeignKeyOverride = foreignKeyOverride.size() > 0 ? foreignKeyOverride : null; }
Example #11
Source File: AbstractPropertyHolder.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Get column overriding, property first, then parent, then holder */ private JoinTable getExactOverriddenJoinTable(String propertyName) { JoinTable override = null; if ( parent != null ) { override = parent.getExactOverriddenJoinTable( propertyName ); } if ( override == null && currentPropertyJoinTableOverride != null ) { override = currentPropertyJoinTableOverride.get( propertyName ); } if ( override == null && holderJoinTableOverride != null ) { override = holderJoinTableOverride.get( propertyName ); } return override; }
Example #12
Source File: AbstractPropertyHolder.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Get column overriding, property first, then parent, then holder * replace the placeholder 'collection&&element' with nothing * * These rules are here to support both JPA 2 and legacy overriding rules. */ @Override public JoinTable getJoinTable(XProperty property) { final String propertyName = StringHelper.qualify( getPath(), property.getName() ); JoinTable result = getOverriddenJoinTable( propertyName ); if (result == null) { result = property.getAnnotation( JoinTable.class ); } return result; }
Example #13
Source File: ColumnsBuilder.java From lams with GNU General Public License v2.0 | 5 votes |
Ejb3JoinColumn[] buildDefaultJoinColumnsForXToOne(XProperty property, PropertyData inferredData) { Ejb3JoinColumn[] joinColumns; JoinTable joinTableAnn = propertyHolder.getJoinTable( property ); if ( joinTableAnn != null ) { joinColumns = Ejb3JoinColumn.buildJoinColumns( joinTableAnn.inverseJoinColumns(), null, entityBinder.getSecondaryTables(), propertyHolder, inferredData.getPropertyName(), buildingContext ); if ( StringHelper.isEmpty( joinTableAnn.name() ) ) { throw new AnnotationException( "JoinTable.name() on a @ToOne association has to be explicit: " + BinderHelper.getPath( propertyHolder, inferredData ) ); } } else { OneToOne oneToOneAnn = property.getAnnotation( OneToOne.class ); String mappedBy = oneToOneAnn != null ? oneToOneAnn.mappedBy() : null; joinColumns = Ejb3JoinColumn.buildJoinColumns( null, mappedBy, entityBinder.getSecondaryTables(), propertyHolder, inferredData.getPropertyName(), buildingContext ); } return joinColumns; }
Example #14
Source File: SCCSubscription.java From uyuni with GNU General Public License v2.0 | 5 votes |
/** * Get the SUSE Products * @return the SUSE Products */ @ManyToMany(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE}) @JoinTable(name = "suseSCCSubscriptionProduct", joinColumns = @JoinColumn(name = "subscription_id"), inverseJoinColumns = @JoinColumn(name = "product_id")) public Set<SUSEProduct> getProducts() { return products; }
Example #15
Source File: ImageOverview.java From uyuni with GNU General Public License v2.0 | 5 votes |
/** * @return the channels */ @ManyToMany(fetch = FetchType.LAZY) @JoinTable(name = "suseImageInfoChannel", joinColumns = { @JoinColumn(name = "image_info_id", nullable = false, updatable = false)}, inverseJoinColumns = { @JoinColumn(name = "channel_id", nullable = false, updatable = false)} ) public Set<Channel> getChannels() { return channels; }
Example #16
Source File: Media.java From aws-photosharing-example with Apache License 2.0 | 5 votes |
@ManyToMany(fetch=FetchType.LAZY, cascade=CascadeType.PERSIST) @JoinTable(name = "album_media", joinColumns = { @JoinColumn(name = "media_id", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "album_id", nullable = false, updatable = false) }) public List<Album> getAlbums() {return albums;}
Example #17
Source File: User.java From base-framework with Apache License 2.0 | 5 votes |
/** * 获取拥有角色 * * @return {@link Role} */ @NotAudited @ManyToMany @JoinTable(name = "TB_ACCOUNT_USER_ROLE", joinColumns = { @JoinColumn(name = "USER_ID") }, inverseJoinColumns = { @JoinColumn(name = "ROLE_ID") }) public List<Role> getRoleList() { return roleList; }
Example #18
Source File: User.java From aws-photosharing-example with Apache License 2.0 | 5 votes |
@XmlTransient @LazyCollection(LazyCollectionOption.EXTRA) @ManyToMany(fetch=FetchType.LAZY, cascade=CascadeType.ALL) @JoinTable(name = "role_mappings", joinColumns = { @JoinColumn(name = "user_id", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "role", nullable = false, updatable = false) }) public List<Role> getRoles() {return _roles;}
Example #19
Source File: ImageInfo.java From uyuni with GNU General Public License v2.0 | 5 votes |
/** * @return the installed installedProducts */ @ManyToMany @JoinTable(name = "suseImageInfoInstalledProduct", joinColumns = { @JoinColumn(name = "image_info_id") }, inverseJoinColumns = { @JoinColumn(name = "installed_product_id") }) public Set<InstalledProduct> getInstalledProducts() { return installedProducts; }
Example #20
Source File: ImageInfo.java From uyuni with GNU General Public License v2.0 | 5 votes |
/** * @return the channels */ @ManyToMany @JoinTable(name = "suseImageInfoChannel", joinColumns = { @JoinColumn(name = "image_info_id") }, inverseJoinColumns = { @JoinColumn(name = "channel_id") }) public Set<Channel> getChannels() { return channels; }
Example #21
Source File: ImageOverview.java From uyuni with GNU General Public License v2.0 | 5 votes |
/** * @return the patches */ @ManyToMany(fetch = FetchType.LAZY) @JoinTable(name = "rhnImageNeededErrataCache", joinColumns = {@JoinColumn(name = "image_id")}, inverseJoinColumns = {@JoinColumn(name = "errata_id")} ) public Set<PublishedErrata> getPatches() { return patches; }
Example #22
Source File: ImageOverview.java From uyuni with GNU General Public License v2.0 | 5 votes |
/** * @return the installed products */ @ManyToMany(fetch = FetchType.LAZY) @JoinTable(name = "suseImageInfoInstalledProduct", joinColumns = { @JoinColumn(name = "image_info_id", nullable = false, updatable = false)}, inverseJoinColumns = { @JoinColumn(name = "installed_product_id", nullable = false, updatable = false) }) public Set<InstalledProduct> getInstalledProducts() { return installedProducts; }
Example #23
Source File: PlmIssue.java From lemon with Apache License 2.0 | 4 votes |
/** @return . */ @ManyToMany(fetch = FetchType.LAZY) @JoinTable(name = "PLM_ISSUE_COMPONENT", joinColumns = { @JoinColumn(name = "ISSUE_ID", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "COMPONENT_ID", nullable = false, updatable = false) }) public Set<PlmComponent> getPlmComponents() { return this.plmComponents; }
Example #24
Source File: Role.java From base-framework with Apache License 2.0 | 4 votes |
@ManyToMany @JoinTable(name = "TB_ACCOUNT_ROLE_MENU", joinColumns = { @JoinColumn(name = "ROLE_ID") }, inverseJoinColumns = { @JoinColumn(name = "MENU_ID") }) public List<Menu> getMenuList() { return menuList; }
Example #25
Source File: PlmIssue.java From lemon with Apache License 2.0 | 4 votes |
/** @return . */ @ManyToMany(fetch = FetchType.LAZY) @JoinTable(name = "PLM_ISSUE_VERSION", joinColumns = { @JoinColumn(name = "ISSUE_ID", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "VERSION_ID", nullable = false, updatable = false) }) public Set<PlmVersion> getPlmVersions() { return this.plmVersions; }
Example #26
Source File: PlmVersion.java From lemon with Apache License 2.0 | 4 votes |
/** @return . */ @ManyToMany(fetch = FetchType.LAZY) @JoinTable(name = "PLM_ISSUE_VERSION", joinColumns = { @JoinColumn(name = "VERSION_ID", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "ISSUE_ID", nullable = false, updatable = false) }) public Set<PlmIssue> getPlmIssues() { return this.plmIssues; }
Example #27
Source File: PlmComponent.java From lemon with Apache License 2.0 | 4 votes |
/** @return . */ @ManyToMany(fetch = FetchType.LAZY) @JoinTable(name = "PLM_ISSUE_COMPONENT", joinColumns = { @JoinColumn(name = "COMPONENT_ID", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "ISSUE_ID", nullable = false, updatable = false) }) public Set<PlmIssue> getPlmIssues() { return this.plmIssues; }
Example #28
Source File: DoorInfo.java From lemon with Apache License 2.0 | 4 votes |
/** @return . */ @ManyToMany(fetch = FetchType.LAZY) @JoinTable(name = "CARD_INFO_DOOR", joinColumns = { @JoinColumn(name = "DOOR_ID", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "INFO_ID", nullable = false, updatable = false) }) public Set<CardInfo> getCardInfos() { return this.cardInfos; }
Example #29
Source File: CardInfo.java From lemon with Apache License 2.0 | 4 votes |
/** @return . */ @ManyToMany(fetch = FetchType.LAZY) @JoinTable(name = "CARD_INFO_DOOR", joinColumns = { @JoinColumn(name = "INFO_ID", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "DOOR_ID", nullable = false, updatable = false) }) public Set<DoorInfo> getDoorInfos() { return this.doorInfos; }
Example #30
Source File: Group.java From base-framework with Apache License 2.0 | 4 votes |
/** * 获取拥有资源 * * @return List */ @ManyToMany(fetch=FetchType.LAZY) @JoinTable(name = "TB_GROUP_RESOURCE", joinColumns = { @JoinColumn(name = "FK_GROUP_ID") }, inverseJoinColumns = { @JoinColumn(name = "FK_RESOURCE_ID") }) public List<Resource> getResourcesList() { return resourcesList; }