private static void checkFilterConditions(Collection collValue) { //for now it can't happen, but sometime soon... if ( ( collValue.getFilters().size() != 0 || StringHelper.isNotEmpty( collValue.getWhere() ) ) && collValue.getFetchMode() == FetchMode.JOIN && !( collValue.getElement() instanceof SimpleValue ) && //SimpleValue (CollectionOfElements) are always SELECT but it does not matter collValue.getElement().getFetchMode() != FetchMode.JOIN ) { throw new MappingException( "@ManyToMany or @CollectionOfElements defining filter or where without join fetching " + "not valid within collection using join fetching[" + collValue.getRole() + "]" ); } }
propFormulaNumbers.add( formnos ); joinedFetchesList.add( prop.getValue().getFetchMode() ); cascades.add( prop.getCascadeStyle() );
/** * @deprecated See mainly {@link #buildEntityBasedAttribute} */ @Deprecated public static StandardProperty buildStandardProperty(Property property, boolean lazyAvailable) { final Type type = property.getValue().getType(); // we need to dirty check collections, since they can cause an owner // version number increment // we need to dirty check many-to-ones with not-found="ignore" in order // to update the cache (not the database), since in this case a null // entity reference can lose information boolean alwaysDirtyCheck = type.isAssociationType() && ( (AssociationType) type ).isAlwaysDirtyChecked(); return new StandardProperty( property.getName(), type, lazyAvailable && property.isLazy(), property.isInsertable(), property.isUpdateable(), property.getValueGenerationStrategy(), property.isOptional(), alwaysDirtyCheck || property.isUpdateable(), property.isOptimisticLocked(), property.getCascadeStyle(), property.getValue().getFetchMode() ); }
.setVersionable( property.isOptimisticLocked() ) .setCascadeStyle( property.getCascadeStyle() ) .setFetchMode( property.getValue().getFetchMode() ) .createInformation() ); .setVersionable( property.isOptimisticLocked() ) .setCascadeStyle( property.getCascadeStyle() ) .setFetchMode( property.getValue().getFetchMode() ) .createInformation() ); .setVersionable( property.isOptimisticLocked() ) .setCascadeStyle( property.getCascadeStyle() ) .setFetchMode( property.getValue().getFetchMode() ) .createInformation() );
fetchMode = collectionBinding.getElement().getFetchMode(); elementType = collectionBinding.getElement().getType();
private static void checkFilterConditions(Collection collValue) { //for now it can't happen, but sometime soon... if ( ( collValue.getFilterMap().size() != 0 || StringHelper.isNotEmpty( collValue.getWhere() ) ) && collValue.getFetchMode() == FetchMode.JOIN && !( collValue.getElement() instanceof SimpleValue ) && //SimpleValue (CollectionOfElements) are always SELECT but it does not matter collValue.getElement().getFetchMode() != FetchMode.JOIN ) { throw new MappingException( "@ManyToMany or @CollectionOfElements defining filter or where without join fetching " + "not valid within collection using join fetching[" + collValue.getRole() + "]" ); } }
public String getFetchMode(Property property) { FetchMode fetchMode = property.getValue().getFetchMode(); return (fetchMode== null) ? null : fetchMode.toString().toLowerCase(); }
public String getFetchMode(Property property) { FetchMode fetchMode = property.getValue().getFetchMode(); return (fetchMode== null) ? null : fetchMode.toString().toLowerCase(); }
private static void checkFilterConditions(Collection collValue) { //for now it can't happen, but sometime soon... if ( ( collValue.getFilterMap().size() != 0 || StringHelper.isNotEmpty( collValue.getWhere() ) ) && collValue.getFetchMode() == FetchMode.JOIN && !( collValue.getElement() instanceof SimpleValue ) && //SimpleValue (CollectionOfElements) are always SELECT but it does not matter collValue.getElement().getFetchMode() != FetchMode.JOIN ) { throw new MappingException( "@ManyToMany or @CollectionOfElements defining filter or where without join fetching " + "not valid within collection using join fetching[" + collValue.getRole() + "]" ); } }
private static void checkFilterConditions(Collection collValue) { //for now it can't happen, but sometime soon... if ( ( collValue.getFilterMap().size() != 0 || StringHelper.isNotEmpty( collValue.getWhere() ) ) && collValue.getFetchMode() == FetchMode.JOIN && !( collValue.getElement() instanceof SimpleValue ) && //SimpleValue (CollectionOfElements) are always SELECT but it does not matter collValue.getElement().getFetchMode() != FetchMode.JOIN ) { throw new MappingException( "@ManyToMany or @CollectionOfElements defining filter or where without join fetching " + "not valid within collection using join fetching[" + collValue.getRole() + "]" ); } }
private static void checkFilterConditions(Collection collValue) { //for now it can't happen, but sometime soon... if ( ( collValue.getFilters().size() != 0 || StringHelper.isNotEmpty( collValue.getWhere() ) ) && collValue.getFetchMode() == FetchMode.JOIN && !( collValue.getElement() instanceof SimpleValue ) && //SimpleValue (CollectionOfElements) are always SELECT but it does not matter collValue.getElement().getFetchMode() != FetchMode.JOIN ) { throw new MappingException( "@ManyToMany or @CollectionOfElements defining filter or where without join fetching " + "not valid within collection using join fetching[" + collValue.getRole() + "]" ); } }
if ( ( filters.hasNext() || whereCondition != null ) && collection.getFetchMode() == FetchMode.JOIN && collection.getElement().getFetchMode() != FetchMode.JOIN ) { throw new MappingException( "many-to-many defining filter or where without join fetching " +
if ( ( filters.hasNext() || whereCondition != null ) && collection.getFetchMode() == FetchMode.JOIN && collection.getElement().getFetchMode() != FetchMode.JOIN ) { throw new MappingException( "many-to-many defining filter or where without join fetching " +
types[j] = prop.getType(); cascade[j] = prop.getCascadeStyle(); joinedFetch[j] = prop.getValue().getFetchMode(); nullabilities[j] = prop.isNullable(); j++;
propFormulaNumbers.add( formnos ); joinedFetchesList.add( prop.getValue().getFetchMode() );
if ( ( filters.hasNext() || whereCondition != null ) && collection.getFetchMode() == FetchMode.JOIN && collection.getElement().getFetchMode() != FetchMode.JOIN ) { throw new MappingException( "many-to-many defining filter or where without join fetching " +
if ( ( filters.hasNext() || whereCondition != null ) && collection.getFetchMode() == FetchMode.JOIN && collection.getElement().getFetchMode() != FetchMode.JOIN ) { throw new MappingException( "many-to-many defining filter or where without join fetching " +
@Test public void testManyToOneAttributeDefaults() { Metadata metadata = MetadataDescriptorFactory .createJdbcDescriptor(null, null, true) .createMetadata(); PersistentClass classMapping = metadata.getEntityBinding("Employee"); Property property = classMapping.getProperty("employee"); Assert.assertEquals("none", property.getCascade()); Assert.assertEquals(true, property.isUpdateable()); Assert.assertEquals(true, property.isInsertable()); Assert.assertEquals("SELECT", property.getValue().getFetchMode().toString()); }
@Test public void testManyToOneAttributeOverrides() { OverrideRepository or = new OverrideRepository(); or.addResource(FOREIGN_KEY_TEST_XML); ReverseEngineeringStrategy repository = or.getReverseEngineeringStrategy(new DefaultReverseEngineeringStrategy()); Metadata metadata = MetadataDescriptorFactory .createJdbcDescriptor(repository, null, true) .createMetadata(); PersistentClass classMapping = metadata.getEntityBinding("Employee"); Property property = classMapping.getProperty("manager"); Assert.assertEquals("all", property.getCascade()); Assert.assertEquals(false, property.isUpdateable()); Assert.assertEquals(false, property.isInsertable()); Assert.assertEquals("JOIN", property.getValue().getFetchMode().toString()); }
@Test public void testOneToOne() throws MalformedURLException, ClassNotFoundException { OverrideRepository or = new OverrideRepository(); or.addResource(FOREIGN_KEY_TEST_XML); ReverseEngineeringStrategy repository = or.getReverseEngineeringStrategy(new DefaultReverseEngineeringStrategy()); Metadata metadata = MetadataDescriptorFactory .createJdbcDescriptor(repository, null, true) .createMetadata(); PersistentClass person = metadata.getEntityBinding("Person"); PersistentClass addressPerson = metadata.getEntityBinding("AddressPerson"); PersistentClass addressMultiPerson = metadata.getEntityBinding("AddressMultiPerson"); PersistentClass multiPerson = metadata.getEntityBinding("MultiPerson"); assertPropertyNotExists(addressPerson, "person", "should be removed by reveng.xml"); assertPropertyNotExists(person, "addressPerson", "should be removed by reveng.xml"); Property property = addressMultiPerson.getProperty("renamedOne"); Assert.assertNotNull(property); Assert.assertEquals("Casade should be set to delete by reveng.xml", "delete", property.getCascade()); assertPropertyNotExists(multiPerson, "addressMultiPerson", "should not be there"); Property o2o = multiPerson.getProperty("renamedInversedOne"); Assert.assertNotNull(o2o); Assert.assertEquals("update", o2o.getCascade()); Assert.assertEquals("JOIN", o2o.getValue().getFetchMode().toString()); }