@Test public void testCollectionTableNoChildren() throws Exception { reader = getReader( Entity3.class, "field1", "element-collection.orm26.xml" ); assertAnnotationPresent( ElementCollection.class ); assertAnnotationPresent( CollectionTable.class ); CollectionTable tableAnno = reader.getAnnotation( CollectionTable.class ); assertEquals( "", tableAnno.name() ); assertEquals( "", tableAnno.catalog() ); assertEquals( "", tableAnno.schema() ); assertEquals( 0, tableAnno.joinColumns().length ); assertEquals( 0, tableAnno.uniqueConstraints().length ); }
/** * Return the full table name */ private String getFullTableName(CollectionTable collectionTable) { if (collectionTable == null || collectionTable.name().isEmpty()) { return null; } StringBuilder sb = new StringBuilder(); if (!StringHelper.isNull(collectionTable.catalog())) { sb.append(collectionTable.catalog()).append("."); } if (!StringHelper.isNull(collectionTable.schema())) { sb.append(collectionTable.schema()).append("."); } sb.append(collectionTable.name()); return sb.toString(); }
assert (ct.name().length() > 0) : "Please sepcify the table for " + attr.field.getName(); StringBuilder selectBuf = new StringBuilder("SELECT "); StringBuilder insertBuf = new StringBuilder("INSERT INTO "); StringBuilder clearBuf = new StringBuilder("DELETE FROM "); clearBuf.append(ct.name()).append(" WHERE "); selectBuf.append(attr.columnName); selectBuf.append(" FROM ").append(ct.name()).append(", ").append(attr.table); selectBuf.append(" WHERE "); insertBuf.append(ct.name()).append("("); StringBuilder valuesBuf = new StringBuilder("SELECT "); selectBuf.append(ct.name()).append(".").append(jc.name()).append("="); if (jc.referencedColumnName().length() == 0) { selectBuf.append(idAttr.table).append(".").append(idAttr.columnName); valuesBuf.append(idAttr.table).append(".").append(idAttr.columnName); clearBuf.append(ct.name()).append(".").append(jc.name()).append("=?"); } else { selectBuf.append(attr.table).append(".").append(jc.referencedColumnName());
catalog = collectionTable.catalog(); schema = collectionTable.schema(); tableName = collectionTable.name(); uniqueConstraints = collectionTable.uniqueConstraints(); joins = collectionTable.joinColumns();
@Override public String getTableName() { return jpaJoinTable.name(); }
assertAnnotationPresent( CollectionTable.class ); CollectionTable tableAnno = reader.getAnnotation( CollectionTable.class ); assertEquals( "table1", tableAnno.name() ); assertEquals( "catalog1", tableAnno.catalog() ); assertEquals( "schema1", tableAnno.schema() );
/** * Return the full table name */ private String getFullTableName(CollectionTable collectionTable) { if (collectionTable == null || collectionTable.name().isEmpty()) { return null; } StringBuilder sb = new StringBuilder(); if (!StringHelper.isNull(collectionTable.catalog())) { sb.append(collectionTable.catalog()).append("."); } if (!StringHelper.isNull(collectionTable.schema())) { sb.append(collectionTable.schema()).append("."); } sb.append(collectionTable.name()); return sb.toString(); }
assert (ct.name().length() > 0) : "Please sepcify the table for " + attr.field.getName(); final StringBuilder selectBuf = new StringBuilder("SELECT "); final StringBuilder insertBuf = new StringBuilder("INSERT INTO "); final StringBuilder clearBuf = new StringBuilder("DELETE FROM "); clearBuf.append(ct.name()).append(" WHERE "); selectBuf.append(attr.columnName); selectBuf.append(" FROM ").append(ct.name()).append(", ").append(attr.table); selectBuf.append(" WHERE "); insertBuf.append(ct.name()).append("("); final StringBuilder valuesBuf = new StringBuilder("SELECT "); selectBuf.append(ct.name()).append(".").append(jc.name()).append("="); if (jc.referencedColumnName().length() == 0) { selectBuf.append(idAttr.table).append(".").append(idAttr.columnName); valuesBuf.append(idAttr.table).append(".").append(idAttr.columnName); clearBuf.append(ct.name()).append(".").append(jc.name()).append("=?"); } else { selectBuf.append(attr.table).append(".").append(jc.referencedColumnName());
public IntermediateCollectionTable(final CollectionTable jpaJoinTable, final IntermediateSchema schema) throws ODataJPAModelException { super(); this.jpaJoinTable = jpaJoinTable; this.jpaEntityType = schema.getEntityType(jpaJoinTable.catalog(), jpaJoinTable.schema(), jpaJoinTable.name()); this.joinColumns = buildJoinColumns(sourceType); }
catalog = collectionTable.catalog(); schema = collectionTable.schema(); tableName = collectionTable.name(); uniqueConstraints = collectionTable.uniqueConstraints(); joins = collectionTable.joinColumns();
/** * @param locator * the java locator * @param annotation * the annotation * * @since 2.0.0 */ public CollectionTableMetadataImpl(AbstractLocator locator, CollectionTable annotation) { super(); this.locator = locator; this.catalog = annotation.catalog(); this.schema = annotation.schema(); this.name = annotation.name(); for (final UniqueConstraint constraint : annotation.uniqueConstraints()) { this.uniqueConstraints.add(new UniqueConstraintMetadataImpl(locator, constraint)); } for (final JoinColumn joinColumn : annotation.joinColumns()) { this.joinColumns.add(new JoinColumnMetadataImpl(this.locator, joinColumn)); } }
/** * @param locator * the java locator * @param annotation * the annotation * * @since 2.0.0 */ public CollectionTableMetadataImpl(AbstractLocator locator, CollectionTable annotation) { super(); this.locator = locator; this.catalog = annotation.catalog(); this.schema = annotation.schema(); this.name = annotation.name(); for (final UniqueConstraint constraint : annotation.uniqueConstraints()) { this.uniqueConstraints.add(new UniqueConstraintMetadataImpl(locator, constraint)); } for (final JoinColumn joinColumn : annotation.joinColumns()) { this.joinColumns.add(new JoinColumnMetadataImpl(this.locator, joinColumn)); } }
/** * @param locator * the java locator * @param annotation * the annotation * * @since 2.0.0 */ public CollectionTableMetadataImpl(AbstractLocator locator, CollectionTable annotation) { super(); this.locator = locator; this.catalog = annotation.catalog(); this.schema = annotation.schema(); this.name = annotation.name(); for (final UniqueConstraint constraint : annotation.uniqueConstraints()) { this.uniqueConstraints.add(new UniqueConstraintMetadataImpl(locator, constraint)); } for (final JoinColumn joinColumn : annotation.joinColumns()) { this.joinColumns.add(new JoinColumnMetadataImpl(this.locator, joinColumn)); } }
public CollectionTableConfig(CollectionTable joinTable) { setName(joinTable.name()); setCatalog(joinTable.catalog()); setSchema(joinTable.schema()); for (JoinColumn joinColumn : joinTable.joinColumns()) { JoinColumnConfig joinColumnConfig = new JoinColumnConfig(joinColumn); addJoinColumn(joinColumnConfig); } }
/** * Parse @CollectionTable. */ protected void parseCollectionTable(FieldMapping fm, CollectionTable ctbl) { FieldMappingInfo info = fm.getMappingInfo(); DBIdentifier tblName = toTableIdentifier(ctbl.schema(), ctbl.name()); info.setTableIdentifier(tblName); //ctbl.catalog() parseJoinColumns(fm, fm.getMappingInfo(), false, ctbl.joinColumns()); addUniqueConstraints(info.getTableIdentifier().getName(), fm.getDefiningMetaData(), info, ctbl.uniqueConstraints()); }
/** * Parse @CollectionTable. */ protected void parseCollectionTable(FieldMapping fm, CollectionTable ctbl) { FieldMappingInfo info = fm.getMappingInfo(); DBIdentifier tblName = toTableIdentifier(ctbl.schema(), ctbl.name()); info.setTableIdentifier(tblName); //ctbl.catalog() parseJoinColumns(fm, fm.getMappingInfo(), false, ctbl.joinColumns()); addUniqueConstraints(info.getTableIdentifier().getName(), fm.getDefiningMetaData(), info, ctbl.uniqueConstraints()); }
/** * Parse @CollectionTable. */ protected void parseCollectionTable(FieldMapping fm, CollectionTable ctbl) { FieldMappingInfo info = fm.getMappingInfo(); DBIdentifier tblName = toTableIdentifier(ctbl.schema(), ctbl.name()); info.setTableIdentifier(tblName); //ctbl.catalog() parseJoinColumns(fm, fm.getMappingInfo(), false, ctbl.joinColumns()); addUniqueConstraints(info.getTableIdentifier().getName(), fm.getDefiningMetaData(), info, ctbl.uniqueConstraints()); }
catalog = collectionTable.catalog(); schema = collectionTable.schema(); tableName = collectionTable.name(); uniqueConstraints = collectionTable.uniqueConstraints(); joins = collectionTable.joinColumns();
catalog = collectionTable.catalog(); schema = collectionTable.schema(); tableName = collectionTable.name(); uniqueConstraints = collectionTable.uniqueConstraints(); joins = collectionTable.joinColumns();