[Hibernate-JIRA] Created: (HHH-3574) ANY mapping ignores lazy="false"
by Manuel Dominguez Sarmiento (JIRA)
ANY mapping ignores lazy="false"
--------------------------------
Key: HHH-3574
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3574
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.1
Reporter: Manuel Dominguez Sarmiento
We have a use case for eager fetching of an <any> association. The DTD accepts lazy="false|true", however at runtime it doesn't make any difference.
Digging deeper, we see that org.hibernate.mapping.Any does not have a lazy property, furthermore, it does not extend Fetchable. This explains why it will not work as expected.
There are two possible resolutions:
1) Implement eager fetching for <any> associations, unless there is some technical difficulty in doing so. Of course lazy fetching won't be possible using joins because of the nature of this type of associations, however it should be simple enough with a second select. This means that the XML config should handle lazy="false|true" but not fetch="join|select|subselect|etc"
2) Fix the DTD in case this can't be done to avoid confusion (less desirable).
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 11 months
[Hibernate-JIRA] Created: (HV-458) Wrong behaviour determining default group constraints in conjunction with @GroupSequence
by Hardy Ferentschik (JIRA)
Wrong behaviour determining default group constraints in conjunction with @GroupSequence
----------------------------------------------------------------------------------------
Key: HV-458
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-458
Project: Hibernate Validator
Issue Type: Bug
Reporter: Hardy Ferentschik
See https://forum.hibernate.org/viewtopic.php?f=9&t=1010136&start=0
In a class hierarchy with more than two classes where the middle class overrides the default group sequence the wrong constraints are executed.
This can be reproduces with
{code}
public class GroupTest {
private static Validator validator;
@BeforeClass
public static void setUp() {
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
validator = factory.getValidator();
}
@Test
public void testDriveAway() {
// create a car and check that everything is ok with it.
Car car = new Car( "Morris", "DD-AB-123", 2 );
Set<ConstraintViolation<Car>> constraintViolations = validator.validate( car );
assertEquals( 0, constraintViolations.size() );
// but has it passed the vehicle inspection?
constraintViolations = validator.validate( car, CarChecks.class );
assertEquals( 1, constraintViolations.size() );
assertEquals(
"The car has to pass the vehicle inspection first", constraintViolations.iterator().next().getMessage()
);
// let's go to the vehicle inspection
car.setPassedVehicleInspection( true );
assertEquals( 0, validator.validate( car ).size() );
// now let's add a driver. He is 18, but has not passed the driving test yet
Driver john = new Driver( "John Doe" );
john.setAge( 18 );
car.setDriver( john );
constraintViolations = validator.validate( car, DriverChecks.class );
assertEquals( 1, constraintViolations.size() );
assertEquals( "You first have to pass the driving test", constraintViolations.iterator().next().getMessage() );
// ok, John passes the test
john.passedDrivingTest( true );
assertEquals( 0, validator.validate( car, DriverChecks.class ).size() );
// just checking that everything is in order now
assertEquals( 0, validator.validate( car, Default.class, CarChecks.class, DriverChecks.class ).size() );
}
@Test
public void testOrderedChecks() {
Car car = new Car( "Morris", "DD-AB-123", 2 );
car.setPassedVehicleInspection( true );
Driver john = new Driver( "John Doe" );
john.setAge( 18 );
john.passedDrivingTest( true );
car.setDriver( john );
assertEquals( 0, validator.validate( car, OrderedChecks.class ).size() );
}
@Test
public void testOrderedChecksWithRedefinedDefault() {
RentalCar rentalCar = new RentalCar( "Morris", "DD-AB-123", 2 );
rentalCar.setPassedVehicleInspection( true );
Driver john = new Driver( "John Doe" );
john.setAge( 18 );
john.passedDrivingTest( true );
rentalCar.setDriver( john );
assertEquals( 0, validator.validate( rentalCar, Default.class, DriverChecks.class ).size() );
}
@Test
public void testOrderedChecksFailsFast() {
RentalCar rentalCar = new RentalCar( "Morris", "DD-AB-123", 0 );
// This should not create a violation exception due to the 0 seat count failing first due to the GroupSequence on RentalCar
rentalCar.setPassedVehicleInspection( false );
Driver john = new Driver( "John Doe" );
john.setAge( 18 );
john.passedDrivingTest( true );
rentalCar.setDriver( john );
assertEquals( 1, validator.validate( rentalCar ).size() );
assertEquals(
validator.validate( rentalCar ).iterator().next()
.getPropertyPath().toString(), "seatCount"
);
rentalCar.setSeatCount( 4 );
assertEquals( 1, validator.validate( rentalCar ).size() );
assertEquals(
validator.validate( rentalCar ).iterator().next()
.getPropertyPath().toString(), "passedVehicleInspection"
);
}
@Test
public void testSubclassesInheritGroupSequence() {
//Our assertion here is based around Item C from Section 3.4.5 of the JSR 303 Validation Spec
//that class X (MiniRentalCar) without explicitly defining a Default group would then inherit
//it's superclasse's "Default" constraints along with it's own attribute level constraints
//not explicitly tied to a group other than Default.
class MiniRentalCar extends RentalCar {
public MiniRentalCar(String manufacturer, String licencePlate, int seatCount) {
super( manufacturer, licencePlate, seatCount );
}
}
MiniRentalCar miniRentalCar = new MiniRentalCar( "Morris", "DD-AB-123", 0 );
// This should not create a violation exception due to the 0 seat count.
miniRentalCar.setPassedVehicleInspection( false );
Driver john = new Driver( "John Doe" );
john.setAge( 18 );
john.passedDrivingTest( true );
miniRentalCar.setDriver( john );
assertEquals( 1, validator.validate( miniRentalCar ).size() );
assertEquals(
validator.validate( miniRentalCar ).iterator().next()
.getPropertyPath().toString(), "seatCount"
);
miniRentalCar.setSeatCount( 4 );
assertEquals( 1, validator.validate( miniRentalCar ).size() );
assertEquals(
validator.validate( miniRentalCar ).iterator().next()
.getPropertyPath().toString(), "passedVehicleInspection"
);
}
@Test
public void testExplicitGroupSequenceOnSubclass() {
//With the testSubclassesInheritGroupSequence test failing, we then try
//a similar test case whereby we explicitly set the Default group for this class.
@GroupSequence( { AnotherMiniRentalCar.class, CarChecks.class })
class AnotherMiniRentalCar extends RentalCar {
public AnotherMiniRentalCar(String manufacturer, String licencePlate, int seatCount) {
super( manufacturer, licencePlate, seatCount );
}
}
AnotherMiniRentalCar anotherMiniRentalCar = new AnotherMiniRentalCar( "Morris", "DD-AB-123", 0 );
// This should not create a violation exception due to the 0 seat count.
anotherMiniRentalCar.setPassedVehicleInspection( false );
Driver john = new Driver( "John Doe" );
john.setAge( 18 );
john.passedDrivingTest( true );
anotherMiniRentalCar.setDriver( john );
assertEquals( 1, validator.validate( anotherMiniRentalCar ).size() );
assertEquals(
validator.validate( anotherMiniRentalCar ).iterator().next()
.getPropertyPath().toString(), "seatCount"
);
anotherMiniRentalCar.setSeatCount( 4 );
assertEquals( 1, validator.validate( anotherMiniRentalCar ).size() );
assertEquals(
validator.validate( anotherMiniRentalCar ).iterator().next()
.getPropertyPath().toString(), "passedVehicleInspection"
);
}
}
{code}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 11 months
[Hibernate-JIRA] Created: (HHH-5276) Table REVINFO created in the default schema even if the property is otherwise set
by Pascal-Eric Servais (JIRA)
Table REVINFO created in the default schema even if the property is otherwise set
---------------------------------------------------------------------------------
Key: HHH-5276
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5276
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 3.5.2
Environment: Hibernate 3.5.2
Mysql (Ver 14.14 Distrib 5.1.37, for debian-linux-gnu (i486))
mysql-connector version 5.1.12
java version "1.6.0_0"
OpenJDK Runtime Environment (IcedTea6 1.6.1) (6b16-1.6.1-3ubuntu3)
OpenJDK Server VM (build 14.0-b16, mixed mode)
Reporter: Pascal-Eric Servais
This issue was first related here : http://community.jboss.org/message/545287 but here is a copy.
Partial configuration :
[META-INF/persistence.xml]
<persistence version="2.0"
<persistence-unit name="party" transaction-type="RESOURCE_LOCAL">
...
<properties>
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost/MODEL?useUnicode=true&characterEncoding=UTF-8" />
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password" value="" />
...
<property name="org.hibernate.envers.default_schema" value="AUDIT"/>
...
<!-- All EventListeners Are Defined -->
</persistence-unit>
[META-INF/orm.xml]
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd"
version="2.0">
<access>FIELD</access>
<entity class="com.company.model.Party">
<table name="PARTY" schema="MODEL" />
...
</entity>
...
</entity-mappings>
As expected, the PARTY table is created into the MODEL schema and the audit table PARTY_AUD is created into the AUDIT schema. But the REVINFO table is created into the MODEL schema. According to the property "org.hibernate.envers.default_schema", it should be created into the AUDIT schema.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 11 months