Java 类javax.persistence.PrimaryKeyJoinColumn 实例源码

项目:lams    文件:JPAOverriddenAnnotationReader.java   
/**
 * @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;
    }
}
项目:lams    文件:JPAOverriddenAnnotationReader.java   
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;
}
项目:org.fastnate    文件:EntityClass.java   
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.");
    }
}
项目:cosmic    文件:DbUtil.java   
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;
}
项目:cosmic    文件:SqlGenerator.java   
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(" ");
    }
}
项目:scheduling    文件:JobData.java   
@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;
}
项目:cloudstack    文件:DbUtil.java   
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;
}
项目:cloudstack    文件:SqlGenerator.java   
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(" ");
    }
}
项目:lams    文件:EntityBinder.java   
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 );
}
项目:oma-riista-web    文件:JpaModelTest.java   
private static boolean isIdField(final Field field) {
    return field.isAnnotationPresent(Id.class) || field.isAnnotationPresent(PrimaryKeyJoinColumn.class);
}
项目:Spring-MVC-Blueprints    文件:Login.java   
@OneToOne(fetch = FetchType.LAZY)
@PrimaryKeyJoinColumn
public CustomerAccount getCustomerAccount() {
    return this.customerAccount;
}
项目:Spring-MVC-Blueprints    文件:Login.java   
@Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
@OneToOne(fetch = FetchType.LAZY)
@PrimaryKeyJoinColumn
public CustomerAccount getCustomerAccount() {
    return this.customerAccount;
}
项目:Spring-MVC-Blueprints    文件:InvoicedProducts.java   
@OneToOne(fetch = FetchType.LAZY)
@PrimaryKeyJoinColumn
public Invoice getInvoice() {
    return this.invoice;
}
项目:Spring-MVC-Blueprints    文件:Login.java   
@OneToOne(fetch = FetchType.LAZY)
@PrimaryKeyJoinColumn
public User getUser() {
    return this.user;
}
项目:Spring-MVC-Blueprints    文件:InvoicedProducts.java   
@OneToOne(fetch = FetchType.LAZY)
@PrimaryKeyJoinColumn
public Invoice getInvoice() {
    return this.invoice;
}
项目:Spring-MVC-Blueprints    文件:Login.java   
@OneToOne(fetch = FetchType.LAZY)
@PrimaryKeyJoinColumn
public User getUser() {
    return this.user;
}
项目:Spring-MVC-Blueprints    文件:Tblgpa.java   
@OneToOne(fetch = FetchType.LAZY)
@PrimaryKeyJoinColumn
public Tblstudents getTblstudents() {
    return this.tblstudents;
}
项目:Spring-MVC-Blueprints    文件:Tblgpa.java   
@OneToOne(fetch = FetchType.LAZY)
@PrimaryKeyJoinColumn
public Tblstudents getTblstudents() {
    return this.tblstudents;
}
项目:Spring-MVC-Blueprints    文件:Login.java   
@OneToOne(fetch = FetchType.LAZY)
@PrimaryKeyJoinColumn
public CustomerInfo getCustomerInfo() {
    return this.customerInfo;
}
项目:cosmic    文件:DbUtil.java   
public static String getReferenceColumn(final PrimaryKeyJoinColumn pkjc) {
    return pkjc.referencedColumnName().length() != 0 ? pkjc.referencedColumnName() : pkjc.name();
}
项目:nics-common    文件:UserInfo.java   
@OneToOne(fetch = FetchType.EAGER)
@PrimaryKeyJoinColumn
public User getUser() {
    return this.user;
}
项目:elide    文件:OneToOneNonRoot.java   
@OneToOne(mappedBy = "otherObject", fetch = FetchType.LAZY)
@PrimaryKeyJoinColumn
public OneToOneRoot getRoot() {
    return root;
}
项目:C1_ParknShop    文件:PsAdItem.java   
@OneToOne(fetch = FetchType.LAZY)
@PrimaryKeyJoinColumn
public PsPromotItem getPsPromotItem() {
    return this.psPromotItem;
}
项目:SyncRunner-Pub    文件:SyncTimes.java   
@OneToOne(fetch = FetchType.LAZY)
@PrimaryKeyJoinColumn
public Channels getChannels() {
    return this.channels;
}
项目:pedal-tx    文件:Secundus.java   
@OneToOne(fetch = FetchType.LAZY)
@PrimaryKeyJoinColumn
public Primus getPrimus() {
    return primus;
}
项目:yscardII    文件:IntegRecords.java   
@OneToOne(fetch = FetchType.LAZY)
@PrimaryKeyJoinColumn
@Cascade(CascadeType.SAVE_UPDATE)
public IntegChange getIntegChange() {
    return integChange;
}
项目:cloudstack    文件:DbUtil.java   
public static String getReferenceColumn(PrimaryKeyJoinColumn pkjc) {
    return pkjc.referencedColumnName().length() != 0 ? pkjc.referencedColumnName() : pkjc.name();
}
项目:fiware-ppl    文件:PiiUniqueId.java   
@OneToOne(cascade = CascadeType.REMOVE)
@PrimaryKeyJoinColumn
public PIIType getPii() {
    return pii;
}