/** * @param mergeWithAnnotations Whether to use Java annotations for this * element, if present and not disabled by the XMLContext defaults. * In some contexts (such as an association mapping) merging with * annotations is never allowed. */ private PrimaryKeyJoinColumns getPrimaryKeyJoinColumns(Element element, XMLContext.Default defaults, boolean mergeWithAnnotations) { PrimaryKeyJoinColumn[] columns = buildPrimaryKeyJoinColumns( element ); if ( mergeWithAnnotations ) { if ( columns.length == 0 && defaults.canUseJavaAnnotations() ) { PrimaryKeyJoinColumn annotation = getPhysicalAnnotation( PrimaryKeyJoinColumn.class ); if ( annotation != null ) { columns = new PrimaryKeyJoinColumn[] { annotation }; } else { PrimaryKeyJoinColumns annotations = getPhysicalAnnotation( PrimaryKeyJoinColumns.class ); columns = annotations != null ? annotations.value() : columns; } } } if ( columns.length > 0 ) { AnnotationDescriptor ad = new AnnotationDescriptor( PrimaryKeyJoinColumns.class ); ad.setValue( "value", columns ); return AnnotationFactory.create( ad ); } else { return null; } }
private PrimaryKeyJoinColumn[] buildPrimaryKeyJoinColumns(Element element) { if ( element == null ) { return new PrimaryKeyJoinColumn[] { }; } List pkJoinColumnElementList = element.elements( "primary-key-join-column" ); PrimaryKeyJoinColumn[] pkJoinColumns = new PrimaryKeyJoinColumn[pkJoinColumnElementList.size()]; int index = 0; Iterator pkIt = pkJoinColumnElementList.listIterator(); while ( pkIt.hasNext() ) { Element subelement = (Element) pkIt.next(); AnnotationDescriptor pkAnn = new AnnotationDescriptor( PrimaryKeyJoinColumn.class ); copyStringAttribute( pkAnn, subelement, "name", false ); copyStringAttribute( pkAnn, subelement, "referenced-column-name", false ); copyStringAttribute( pkAnn, subelement, "column-definition", false ); pkJoinColumns[index++] = AnnotationFactory.create( pkAnn ); } return pkJoinColumns; }
private void buildPrimaryKeyJoinColumn() { if (this.joinedParentClass.getIdProperty() instanceof SingularProperty) { final PrimaryKeyJoinColumn pkColumn = this.entityClass.getAnnotation(PrimaryKeyJoinColumn.class); final String columnName; if (pkColumn == null || StringUtils.isEmpty(pkColumn.name())) { columnName = ((SingularProperty<? super E, ?>) this.joinedParentClass.getIdProperty()).getColumn() .getName(); } else { columnName = pkColumn.name(); } this.primaryKeyJoinColumn = this.table.resolveColumn(columnName); } else { throw new IllegalArgumentException( "JOINED inheritance strategy is currently only supported with singular ID properties."); } }
public static PrimaryKeyJoinColumn[] getPrimaryKeyJoinColumns(final Class<?> clazz) { final PrimaryKeyJoinColumn pkjc = clazz.getAnnotation(PrimaryKeyJoinColumn.class); if (pkjc != null) { return new PrimaryKeyJoinColumn[]{pkjc}; } final PrimaryKeyJoinColumns pkjcs = clazz.getAnnotation(PrimaryKeyJoinColumns.class); if (pkjcs != null) { return pkjcs.value(); } return null; }
protected static void addPrimaryKeyJoinColumns(final StringBuilder sql, final String fromTable, final String toTable, final String joinType, final PrimaryKeyJoinColumn[] pkjcs) { if ("right".equalsIgnoreCase(joinType)) { sql.append(" RIGHT JOIN ").append(toTable).append(" ON "); } else if ("left".equalsIgnoreCase(joinType)) { sql.append(" LEFT JOIN ").append(toTable).append(" ON "); } else { sql.append(" INNER JOIN ").append(toTable).append(" ON "); } for (final PrimaryKeyJoinColumn pkjc : pkjcs) { sql.append(fromTable).append(".").append(pkjc.name()); final String refColumn = DbUtil.getReferenceColumn(pkjc); sql.append("=").append(toTable).append(".").append(refColumn).append(" "); } }
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "jobData") @Fetch(FetchMode.SELECT) @BatchSize(size = 10) @MapKey(name = "jobId") @PrimaryKeyJoinColumn(name = "JOB_ID") public List<JobContent> getJobContent() { return jobContent; }
public static PrimaryKeyJoinColumn[] getPrimaryKeyJoinColumns(Class<?> clazz) { PrimaryKeyJoinColumn pkjc = clazz.getAnnotation(PrimaryKeyJoinColumn.class); if (pkjc != null) { return new PrimaryKeyJoinColumn[] {pkjc}; } PrimaryKeyJoinColumns pkjcs = clazz.getAnnotation(PrimaryKeyJoinColumns.class); if (pkjcs != null) { return pkjcs.value(); } return null; }
protected static void addPrimaryKeyJoinColumns(StringBuilder sql, String fromTable, String toTable, String joinType, PrimaryKeyJoinColumn[] pkjcs) { if ("right".equalsIgnoreCase(joinType)) { sql.append(" RIGHT JOIN ").append(toTable).append(" ON "); } else if ("left".equalsIgnoreCase(joinType)) { sql.append(" LEFT JOIN ").append(toTable).append(" ON "); } else { sql.append(" INNER JOIN ").append(toTable).append(" ON "); } for (PrimaryKeyJoinColumn pkjc : pkjcs) { sql.append(fromTable).append(".").append(pkjc.name()); String refColumn = DbUtil.getReferenceColumn(pkjc); sql.append("=").append(toTable).append(".").append(refColumn).append(" "); } }
private void createPrimaryColumnsToSecondaryTable(Object uncastedColumn, PropertyHolder propertyHolder, Join join) { Ejb3JoinColumn[] ejb3JoinColumns; PrimaryKeyJoinColumn[] pkColumnsAnn = null; JoinColumn[] joinColumnsAnn = null; if ( uncastedColumn instanceof PrimaryKeyJoinColumn[] ) { pkColumnsAnn = (PrimaryKeyJoinColumn[]) uncastedColumn; } if ( uncastedColumn instanceof JoinColumn[] ) { joinColumnsAnn = (JoinColumn[]) uncastedColumn; } if ( pkColumnsAnn == null && joinColumnsAnn == null ) { ejb3JoinColumns = new Ejb3JoinColumn[1]; ejb3JoinColumns[0] = Ejb3JoinColumn.buildJoinColumn( null, null, persistentClass.getIdentifier(), secondaryTables, propertyHolder, mappings ); } else { int nbrOfJoinColumns = pkColumnsAnn != null ? pkColumnsAnn.length : joinColumnsAnn.length; if ( nbrOfJoinColumns == 0 ) { ejb3JoinColumns = new Ejb3JoinColumn[1]; ejb3JoinColumns[0] = Ejb3JoinColumn.buildJoinColumn( null, null, persistentClass.getIdentifier(), secondaryTables, propertyHolder, mappings ); } else { ejb3JoinColumns = new Ejb3JoinColumn[nbrOfJoinColumns]; if ( pkColumnsAnn != null ) { for (int colIndex = 0; colIndex < nbrOfJoinColumns; colIndex++) { ejb3JoinColumns[colIndex] = Ejb3JoinColumn.buildJoinColumn( pkColumnsAnn[colIndex], null, persistentClass.getIdentifier(), secondaryTables, propertyHolder, mappings ); } } else { for (int colIndex = 0; colIndex < nbrOfJoinColumns; colIndex++) { ejb3JoinColumns[colIndex] = Ejb3JoinColumn.buildJoinColumn( null, joinColumnsAnn[colIndex], persistentClass.getIdentifier(), secondaryTables, propertyHolder, mappings ); } } } } for (Ejb3JoinColumn joinColumn : ejb3JoinColumns) { joinColumn.forceNotNull(); } bindJoinToPersistentClass( join, ejb3JoinColumns, mappings ); }
private static boolean isIdField(final Field field) { return field.isAnnotationPresent(Id.class) || field.isAnnotationPresent(PrimaryKeyJoinColumn.class); }
@OneToOne(fetch = FetchType.LAZY) @PrimaryKeyJoinColumn public CustomerAccount getCustomerAccount() { return this.customerAccount; }
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE) @OneToOne(fetch = FetchType.LAZY) @PrimaryKeyJoinColumn public CustomerAccount getCustomerAccount() { return this.customerAccount; }
@OneToOne(fetch = FetchType.LAZY) @PrimaryKeyJoinColumn public Invoice getInvoice() { return this.invoice; }
@OneToOne(fetch = FetchType.LAZY) @PrimaryKeyJoinColumn public User getUser() { return this.user; }
@OneToOne(fetch = FetchType.LAZY) @PrimaryKeyJoinColumn public Tblstudents getTblstudents() { return this.tblstudents; }
@OneToOne(fetch = FetchType.LAZY) @PrimaryKeyJoinColumn public CustomerInfo getCustomerInfo() { return this.customerInfo; }
public static String getReferenceColumn(final PrimaryKeyJoinColumn pkjc) { return pkjc.referencedColumnName().length() != 0 ? pkjc.referencedColumnName() : pkjc.name(); }
@OneToOne(fetch = FetchType.EAGER) @PrimaryKeyJoinColumn public User getUser() { return this.user; }
@OneToOne(mappedBy = "otherObject", fetch = FetchType.LAZY) @PrimaryKeyJoinColumn public OneToOneRoot getRoot() { return root; }
@OneToOne(fetch = FetchType.LAZY) @PrimaryKeyJoinColumn public PsPromotItem getPsPromotItem() { return this.psPromotItem; }
@OneToOne(fetch = FetchType.LAZY) @PrimaryKeyJoinColumn public Channels getChannels() { return this.channels; }
@OneToOne(fetch = FetchType.LAZY) @PrimaryKeyJoinColumn public Primus getPrimus() { return primus; }
@OneToOne(fetch = FetchType.LAZY) @PrimaryKeyJoinColumn @Cascade(CascadeType.SAVE_UPDATE) public IntegChange getIntegChange() { return integChange; }
public static String getReferenceColumn(PrimaryKeyJoinColumn pkjc) { return pkjc.referencedColumnName().length() != 0 ? pkjc.referencedColumnName() : pkjc.name(); }
@OneToOne(cascade = CascadeType.REMOVE) @PrimaryKeyJoinColumn public PIIType getPii() { return pii; }