private Map<String, String> getReferenceColumnNamesMapForReferenceAttribute(SingularAttribute<?, ?> attribute, ManagedType<?> targetEntity) { List<String> idAttributeNames = targetEntity.getSingularAttributes().stream() .filter(this::isIdAttribute) .map(this::getSingularAttributeColumnName) .collect(Collectors.toList()); JoinColumns joinColumnsAnnotation = ((AnnotatedElement) attribute.getJavaMember()).getAnnotation(JoinColumns.class); JoinColumn joinColumnAnnotation = ((AnnotatedElement) attribute.getJavaMember()).getAnnotation(JoinColumn.class); JoinColumn[] joinColumns = joinColumnsAnnotation != null ? joinColumnsAnnotation.value() : joinColumnAnnotation != null ? new JoinColumn[]{joinColumnAnnotation} : null; Map<String, String> referenceColumnNamesMap; if (joinColumns != null) { referenceColumnNamesMap = Arrays.stream(joinColumns) .collect(Collectors.toMap(JoinColumn::name, joinColumn -> joinColumn.referencedColumnName().length() > 0 ? joinColumn.referencedColumnName() : idAttributeNames.get(0))); } else { referenceColumnNamesMap = idAttributeNames.stream() .collect(Collectors.toMap(idAttributeName -> attribute.getName().toUpperCase() + "_" + idAttributeName, idAttributeName -> idAttributeName)); } return referenceColumnNamesMap; }
private void addForeignKey(final Attribute<?, ?> jpaAttribute) throws ODataJPAModelException, ODataJPARuntimeException { AnnotatedElement annotatedElement = (AnnotatedElement) jpaAttribute.getJavaMember(); joinColumnNames = null; if (annotatedElement == null) { return; } JoinColumn joinColumn = annotatedElement.getAnnotation(JoinColumn.class); if (joinColumn == null) { JoinColumns joinColumns = annotatedElement.getAnnotation(JoinColumns.class); if (joinColumns != null) { for (JoinColumn jc : joinColumns.value()) { buildForeignKey(jc, jpaAttribute); } } } else { buildForeignKey(joinColumn, jpaAttribute); } }
private void buildJoinColumns(List<Annotation> annotationList, Element element) { JoinColumn[] joinColumns = getJoinColumns( element, false ); if ( joinColumns.length > 0 ) { AnnotationDescriptor ad = new AnnotationDescriptor( JoinColumns.class ); ad.setValue( "value", joinColumns ); annotationList.add( AnnotationFactory.create( ad ) ); } }
@OneToOne(cascade = CascadeType.PERSIST) @JoinColumns ({ @JoinColumn(name = "view" , referencedColumnName = "dataid" ), @JoinColumn(name = "creater" , referencedColumnName = "creater" ) }) public TopicView getView() { return view; }
@ForeignKey(name = "none") @MapsId("record") @ManyToOne(fetch = FetchType.LAZY) @JoinColumns({ @JoinColumn(name = COLUMN_RECORD_ID, referencedColumnName = "id") }) public RAuditEventRecord getRecord() { return record; }
@ManyToOne(fetch = FetchType.LAZY) @JoinColumns({ @JoinColumn(name = "unit_id", referencedColumnName = "unit_id", nullable = false), @JoinColumn(name = "operational_period_id", referencedColumnName = "operational_period_id", nullable = false) }) public Assignment getAssignment() { return this.assignment; }
@NotNull @ManyToOne(optional = false, fetch = FetchType.LAZY) @JoinColumns(value = { @JoinColumn(name = "storage_owner_id", referencedColumnName = "owner_id", insertable = false, updatable = false), @JoinColumn(name = "storage_name", referencedColumnName = "name", insertable = false, updatable = false) }, foreignKey = @ForeignKey(name = RdbmsConstants.PREFIX + "storage_tag_object_statistics_fk_storage")) public Storage getStorage() { return storage; }
@NotNull @ManyToOne(optional = false, fetch = FetchType.LAZY) @JoinColumns( foreignKey = @ForeignKey(name = RdbmsConstants.PREFIX + "bucket_object_version_fk_bucket_object"), value = { @JoinColumn(name = "bucket_id", referencedColumnName = "bucket_id", insertable = false, updatable = false), @JoinColumn(name = "object_name", referencedColumnName = "name", insertable = false, updatable = false) }) public BucketObject getBucketObject() { return bucketObject; }
@NotNull @ManyToOne(optional = false, fetch = FetchType.LAZY) @JoinColumns( foreignKey = @ForeignKey(name = RdbmsConstants.PREFIX + "bucket_object_version_fk_storage"), value = { @JoinColumn(name = "storage_owner_id", referencedColumnName = "owner_id"), @JoinColumn(name = "storage_name", referencedColumnName = "name") }) public Storage getStorage() { return storage; }
@ManyToOne(optional = true, fetch = FetchType.LAZY) @JoinColumns( foreignKey = @ForeignKey(name = RdbmsConstants.PREFIX + "bucket_object_fk_content_version"), value = { @JoinColumn(name = "bucket_id", referencedColumnName = "bucket_id", insertable = false, updatable = false), @JoinColumn(name = "name", referencedColumnName = "object_name", insertable = false, updatable = false), @JoinColumn(name = "content_version_uuid", referencedColumnName = "version_uuid", insertable = false, updatable = false) }) public BucketObjectVersion getContentVersion() { return contentVersion; }
@NotNull @ManyToOne(optional = false, fetch = FetchType.LAZY) @JoinColumns( foreignKey = @ForeignKey(name = RdbmsConstants.PREFIX + "bucket_fk_storage"), value = { @JoinColumn(name = "storage_owner", referencedColumnName = "owner_id"), @JoinColumn(name = "storage_name", referencedColumnName = "name") }) public Storage getStorage() { return storage; }
@NotNull @ManyToOne(optional = false, fetch = FetchType.LAZY) @JoinColumns(value = { @JoinColumn(name = "quota_plan_id", referencedColumnName = "quota_model_id"), @JoinColumn(name = "quota_plan_limit", referencedColumnName = "gigabyte_limit") }, foreignKey = @ForeignKey(name = RdbmsConstants.PREFIX + "storage_fk_quota_plan")) public StorageQuotaPlan getQuotaPlan() { return quotaPlan; }
@ManyToOne(fetch = FetchType.LAZY) @JoinColumns({ @JoinColumn(name = "players_has_quests_players_idplayers", referencedColumnName = "players_idplayers", nullable = false, insertable = false, updatable = false), @JoinColumn(name = "players_has_quests_quests_idquests", referencedColumnName = "quests_idquests", nullable = false, insertable = false, updatable = false) }) public PlayersHasQuests getPlayersHasQuests() { return this.playersHasQuests; }
@ManyToOne(fetch = FetchType.EAGER) @JoinColumns({ @JoinColumn(name = "places_has_transports_places_origin", referencedColumnName = "places_origin", nullable = false, insertable = false, updatable = false), @JoinColumn(name = "places_has_transports_transportation", referencedColumnName = "transportation", nullable = false, insertable = false, updatable = false), @JoinColumn(name = "places_has_transports_places_destination", referencedColumnName = "places_destination", nullable = false, insertable = false, updatable = false) }) public PlacesHasTransports getPlacesHasTransports() { return this.placesHasTransports; }
@ManyToOne(fetch = FetchType.LAZY) @JoinColumns({ @JoinColumn(name = "turns_history_players_has_quests_players_idplayers", referencedColumnName = "players_has_quests_players_idplayers", nullable = false, insertable = false, updatable = false), @JoinColumn(name = "turns_history_players_has_quests_quests_idquests", referencedColumnName = "players_has_quests_quests_idquests", nullable = false, insertable = false, updatable = false), @JoinColumn(name = "turns_history_places_has_transports_places_origin", referencedColumnName = "places_has_transports_places_origin", nullable = false, insertable = false, updatable = false), @JoinColumn(name = "turns_history_places_has_transports_transportation", referencedColumnName = "places_has_transports_transportation", nullable = false, insertable = false, updatable = false), @JoinColumn(name = "turns_history_places_has_transports_places_destination", referencedColumnName = "places_has_transports_places_destination", nullable = false, insertable = false, updatable = false) }) public TurnsHistory getTurnsHistory() { return this.turnsHistory; }
private static JoinPath getHint(FieldAnnotationProvider annos, AbstractMetadata meta, ITableMetadata target) { if (annos.getAnnotation(JoinColumn.class) != null) { JoinColumn j = annos.getAnnotation(JoinColumn.class); return processJoin(meta, target, annos, j); } else if (annos.getAnnotation(JoinColumns.class) != null) { JoinColumns jj = annos.getAnnotation(JoinColumns.class); return processJoin(meta, target, annos, jj.value()); } else if (annos.getAnnotation(JoinTable.class) != null) { JoinTable jt = annos.getAnnotation(JoinTable.class); return processJoin(meta, target, annos, jt); } return null; }
public XAnnotation<?> createJoinColumns(List<JoinColumn> cJoinColumns) { return transform( JoinColumns.class, javax.persistence.JoinColumn.class, cJoinColumns, new Transformer<JoinColumn, XAnnotation<javax.persistence.JoinColumn>>() { public XAnnotation<javax.persistence.JoinColumn> transform( JoinColumn input) { return createJoinColumn(input); } }); }
@ManyToOne(fetch=FetchType.EAGER,cascade = CascadeType.MERGE) @JoinColumns ({ @JoinColumn(name="isin", referencedColumnName = "isin"), @JoinColumn(name="symbol", referencedColumnName = "symbol") }) @Id public Stock getStock() { return stock; }
@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH) @JoinColumns( { @JoinColumn(name = "isin", referencedColumnName = "isin"), @JoinColumn(name = "symbol", referencedColumnName = "symbol") }) @ForeignKey(name = "FK_STOCK") @Id public Stock getStock() { return stock; }
@Id @ManyToOne @ForeignKey(name="FK_ALERTONEVENT_TO_PORTFOLIO") @JoinColumns({ @JoinColumn(name="symbol", referencedColumnName="symbol" , nullable = false), @JoinColumn(name="isin", referencedColumnName="isin", nullable = false), @JoinColumn(name="name", referencedColumnName="name", nullable = false) }) public PortfolioShare getPortfolioShare() { return portfolioShare; }
@Id @ManyToOne @ForeignKey(name="FK_ALERTS_TO_PORTFOLIO") @JoinColumns({ @JoinColumn(name="symbol", referencedColumnName="symbol" , nullable = false), @JoinColumn(name="isin", referencedColumnName="isin", nullable = false), @JoinColumn(name="name", referencedColumnName="name", nullable = false) }) public PortfolioShare getPortfolioShare() { return portfolioShare; }
@ManyToOne @JoinColumns( { @JoinColumn(name = "isin", referencedColumnName = "isin", insertable = false, updatable = false, nullable = false), @JoinColumn(name = "symbol", referencedColumnName = "symbol", insertable = false, updatable = false, nullable = false) }) public Stock getStock() { return stock; }
@ManyToOne(cascade = {}, fetch = FetchType.LAZY) @JoinColumns({ @JoinColumn(name = "application_id",nullable = false, insertable = false, updatable = false) }) public Application getApplication() { return application; }
@ManyToOne(cascade = {}, fetch = FetchType.LAZY) @JoinColumns({ @JoinColumn(name = "rely_application_id",nullable = false, insertable = false, updatable = false) }) public Application getRelyApplication() { return relyApplication; }
@ManyToOne(cascade = {}, fetch = FetchType.EAGER) @JoinColumns({ @JoinColumn(name = "application_id",nullable = false, insertable = false, updatable = false) }) public Application getApplication() { return application; }
@ManyToOne(cascade = {}, fetch = FetchType.LAZY) @JoinColumns({ @JoinColumn(name = "parent_id",nullable = true, insertable = false, updatable = false) }) public Permission getParentPermission() { return parentPermission; }
@ManyToOne(cascade = {}, fetch = FetchType.LAZY) @JoinColumns({ @JoinColumn(name = "parent_id",nullable = true, insertable = false, updatable = false) }) public Resources getResources() { return resources; }
@ManyToOne(cascade = {}, fetch = FetchType.EAGER) @JoinColumns({ @JoinColumn(name = "permission_id",nullable = true, insertable = false, updatable = false) }) public Permission getPermission() { return permission; }
@ManyToOne(cascade = {}, fetch = FetchType.LAZY) @JoinColumns({ @JoinColumn(name = "parent_id",nullable = false, insertable = false, updatable = false) }) public Dictvalue getDictvalue() { return dictvalue; }
@ManyToOne(cascade = {}, fetch = FetchType.EAGER) @JoinColumns({ @JoinColumn(name = "dictitem_id",nullable = false, insertable = false, updatable = false) }) public Dictitem getDictitem() { return dictitem; }
@ManyToOne(cascade = {}, fetch = FetchType.LAZY) @JoinColumns({ @JoinColumn(name = "resources_id",nullable = true, insertable = true, updatable = true) }) public RsResources getRsResources() { return rsResources; }
@ManyToOne(cascade = {}, fetch = FetchType.LAZY) @JoinColumns({ @JoinColumn(name = "resources_type_id",nullable = false, insertable = false, updatable = false) }) public RsType getRsType() { return rsType; }
@ManyToOne(cascade = {}, fetch = FetchType.LAZY) @JoinColumns({ @JoinColumn(name = "upload_user_id",nullable = false, insertable = false, updatable = false) }) public User getOgUser() { return ogUser; }
@ManyToOne(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY) @JoinColumns({ @JoinColumn(name = "parentId",nullable = true, insertable = false, updatable = false) }) public Organization getOrganization() { return organization; }
@ManyToOne(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY) @JoinColumns({ @JoinColumn(name = "managerId",nullable = true, insertable = false, updatable = false) }) public User getManager() { return manager; }
@ManyToOne(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY) @JoinColumns({ @JoinColumn(name = "parentId",nullable = true, insertable = false, updatable = false) }) public Dept getDept() { return dept; }
@ManyToOne(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY) @JoinColumns({ @JoinColumn(name = "leaderId",nullable = true, insertable = false, updatable = false) }) public User getLeader() { return leader; }