protected boolean supportsElementCollection(Field field) { ElementCollection otm = field.getAnnotation(ElementCollection.class); if (otm.fetch() == FetchType.LAZY) { assert (false) : "Doesn't support laz fetch: " + field.getName(); return false; } CollectionTable ct = field.getAnnotation(CollectionTable.class); if (ct == null) { assert (false) : "No collection table sepcified for " + field.getName(); return false; } return true; }
fetchType = elementCollection.fetch();
@Test public void testNoChildren() throws Exception { reader = getReader( Entity2.class, "field1", "element-collection.orm1.xml" ); assertAnnotationPresent( ElementCollection.class ); assertAnnotationNotPresent( OrderBy.class ); assertAnnotationNotPresent( OrderColumn.class ); assertAnnotationNotPresent( MapKey.class ); assertAnnotationNotPresent( MapKeyClass.class ); assertAnnotationNotPresent( MapKeyTemporal.class ); assertAnnotationNotPresent( MapKeyEnumerated.class ); assertAnnotationNotPresent( MapKeyColumn.class ); assertAnnotationNotPresent( MapKeyJoinColumns.class ); assertAnnotationNotPresent( MapKeyJoinColumn.class ); assertAnnotationNotPresent( Column.class ); assertAnnotationNotPresent( Temporal.class ); assertAnnotationNotPresent( Enumerated.class ); assertAnnotationNotPresent( Lob.class ); assertAnnotationNotPresent( AttributeOverride.class ); assertAnnotationNotPresent( AttributeOverrides.class ); assertAnnotationNotPresent( AssociationOverride.class ); assertAnnotationNotPresent( AssociationOverrides.class ); assertAnnotationNotPresent( CollectionTable.class ); assertAnnotationNotPresent( Access.class ); ElementCollection relAnno = reader.getAnnotation( ElementCollection.class ); assertEquals( FetchType.LAZY, relAnno.fetch() ); assertEquals( void.class, relAnno.targetClass() ); }
assertAnnotationPresent( Access.class ); ElementCollection relAnno = reader.getAnnotation( ElementCollection.class ); assertEquals( FetchType.EAGER, relAnno.fetch() ); assertEquals( Entity3.class, relAnno.targetClass() ); assertEquals(
protected boolean supportsElementCollection(final Field field) { final ElementCollection otm = field.getAnnotation(ElementCollection.class); if (otm.fetch() == FetchType.LAZY) { assert (false) : "Doesn't support laz fetch: " + field.getName(); return false; } final CollectionTable ct = field.getAnnotation(CollectionTable.class); if (ct == null) { assert (false) : "No collection table sepcified for " + field.getName(); return false; } return true; }
private void introspectElementCollection(ElementCollection eltCollection) { Class targetClass = eltCollection.targetClass(); if (! void.class.equals(targetClass)) setTargetClass(targetClass); setFetch(eltCollection.fetch()); }
fetchType = elementCollection.fetch();
this.fetchType = elementCollection.fetch();
this.fetchType = elementCollection.fetch();
this.fetchType = elementCollection.fetch();
return (ec.fetch() == FetchType.LAZY);
return (ec.fetch() == FetchType.LAZY);
return (ec.fetch() == FetchType.LAZY);
return (ec.fetch() == FetchType.LAZY);
return (ec.fetch() == FetchType.LAZY);
/** * Parse @ElementCollection. */ private void parseElementCollection(FieldMetaData fmd, ElementCollection anno) { // TODO: throw exception if the runtime env is OpenJpa 1.x if (fmd.getDeclaredTypeCode() != JavaTypes.COLLECTION && fmd.getDeclaredTypeCode() != JavaTypes.MAP) throw new MetaDataException(_loc.get("bad-meta-anno", fmd, "ElementCollection")); if (anno.targetClass() != void.class) fmd.getElement().setDeclaredType(anno.targetClass()); fmd.setInDefaultFetchGroup(anno.fetch() == FetchType.EAGER); fmd.setElementCollection(true); ValueMetaData elem = fmd.getElement(); boolean isEnum = elem.getDeclaredType().isEnum(); if (!isEnum && JavaTypes.maybePC(elem)) { elem.setEmbedded(true); if (elem.getEmbeddedMetaData() == null) elem.addEmbeddedMetaData(getAccessCode(elem.getDeclaredType())); } }
/** * Parse @ElementCollection. */ private void parseElementCollection(FieldMetaData fmd, ElementCollection anno) { // TODO: throw exception if the runtime env is OpenJpa 1.x if (fmd.getDeclaredTypeCode() != JavaTypes.COLLECTION && fmd.getDeclaredTypeCode() != JavaTypes.MAP) throw new MetaDataException(_loc.get("bad-meta-anno", fmd, "ElementCollection")); if (anno.targetClass() != void.class) fmd.getElement().setDeclaredType(anno.targetClass()); fmd.setInDefaultFetchGroup(anno.fetch() == FetchType.EAGER); fmd.setElementCollection(true); ValueMetaData elem = fmd.getElement(); boolean isEnum = elem.getDeclaredType().isEnum(); if (!isEnum && JavaTypes.maybePC(elem)) { elem.setEmbedded(true); if (elem.getEmbeddedMetaData() == null) elem.addEmbeddedMetaData(getAccessCode(elem.getDeclaredType())); } }
/** * Parse @ElementCollection. */ private void parseElementCollection(FieldMetaData fmd, ElementCollection anno) { // TODO: throw exception if the runtime env is OpenJpa 1.x if (fmd.getDeclaredTypeCode() != JavaTypes.COLLECTION && fmd.getDeclaredTypeCode() != JavaTypes.MAP) throw new MetaDataException(_loc.get("bad-meta-anno", fmd, "ElementCollection")); if (anno.targetClass() != void.class) fmd.getElement().setDeclaredType(anno.targetClass()); fmd.setInDefaultFetchGroup(anno.fetch() == FetchType.EAGER); fmd.setElementCollection(true); ValueMetaData elem = fmd.getElement(); boolean isEnum = elem.getDeclaredType().isEnum(); if (!isEnum && JavaTypes.maybePC(elem)) { elem.setEmbedded(true); if (elem.getEmbeddedMetaData() == null) elem.addEmbeddedMetaData(getAccessCode(elem.getDeclaredType())); } }
/** * Parse @ElementCollection. */ private void parseElementCollection(FieldMetaData fmd, ElementCollection anno) { // TODO: throw exception if the runtime env is OpenJpa 1.x if (fmd.getDeclaredTypeCode() != JavaTypes.COLLECTION && fmd.getDeclaredTypeCode() != JavaTypes.MAP) throw new MetaDataException(_loc.get("bad-meta-anno", fmd, "ElementCollection")); if (anno.targetClass() != void.class) fmd.getElement().setDeclaredType(anno.targetClass()); fmd.setInDefaultFetchGroup(anno.fetch() == FetchType.EAGER); fmd.setElementCollection(true); ValueMetaData elem = fmd.getElement(); boolean isEnum = elem.getDeclaredType().isEnum(); if (!isEnum && JavaTypes.maybePC(elem)) { elem.setEmbedded(true); if (elem.getEmbeddedMetaData() == null) elem.addEmbeddedMetaData(getAccessCode(elem.getDeclaredType())); } }
&& elemCollectionAnnotation.fetch() != FetchType.EAGER; boolean lazyAssociation = attr.isAssociation() && (fetchType == null || fetchType == FetchType.LAZY);