[Hibernate-JIRA] Created: (HV-64) Field annotated member validators does not work with proxied objects
by Lucien Weller (JIRA)
Field annotated member validators does not work with proxied objects
--------------------------------------------------------------------
Key: HV-64
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-64
Project: Hibernate Validator
Issue Type: Bug
Components: engine
Affects Versions: 3.1.0.CR1, 3.0.0.ga
Reporter: Lucien Weller
Attachments: getter-fix.patch
Every thing works fine, except when I try to validate an persistent instance laded directly from database (which should obviously be valid) we get some invalid values reported by hibernate class validator.
After debuging hibernate validator code, I discovered that it is because we annotate our hibernate classes on field level with validator anotaions (getter and setter are generated in our project). Hibernate validator then tries to retrive the value directly by accessing the field it self. But if the instance is a proxied object (due to lazy loading), fields don't hold the correct value (in fact they all set to null) and validator then reports an invalid value if field is annotated with not null validator.
I simply fixed this isse by accessing fields with their getter rather than by a direct access if a getter has been defined. Now validation also works fine with persistent proxied instances loaded from database.
The corresponding patch is attached to the present issue report, hoping this will be fixed in 3.1.0.GA release
--
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
16 years, 5 months
[Hibernate-JIRA] Created: (HHH-3199) Some query fail in BinaryLogicOperatorNode.mutateRowValueConstructorSyntaxesIfNecessary when there is a one-to-one bidi relation.
by Benjamin Lerman (JIRA)
Some query fail in BinaryLogicOperatorNode.mutateRowValueConstructorSyntaxesIfNecessary when there is a one-to-one bidi relation.
---------------------------------------------------------------------------------------------------------------------------------
Key: HHH-3199
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3199
Project: Hibernate3
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.6
Environment: Hibernate version 3.2.6.ga. Database postgreSQL,
Reporter: Benjamin Lerman
Attachments: example.zip
When mapping a one-to-one bidi relation with the following mappings :
<hibernate-mapping>
<class lazy="true" name="com.genia.toolbox.model.association.one_to_one_bidi.impl.DriverOneToOneBidiImpl" proxy="com.genia.toolbox.model.association.one_to_one_bidi.DriverOneToOneBidi" table="_driver_one_to_one_bidi">
<id name="identifier" column="_identifier" type="java.lang.Long" unsaved-value="null">
<generator class="hilo"><param name="table">_hibernate_unique_key_169</param></generator>
</id>
<one-to-one cascade="persist,merge,save-update" class="com.genia.toolbox.model.association.one_to_one_bidi.impl.CarOneToOneBidiImpl" name="carInternal" property-ref="driverInternal"/>
</class>
</hibernate-mapping>
and
<hibernate-mapping>
<class lazy="true" name="com.genia.toolbox.model.association.one_to_one_bidi.impl.CarOneToOneBidiImpl" proxy="com.genia.toolbox.model.association.one_to_one_bidi.CarOneToOneBidi" table="_car_one_to_one_bidi">
<id name="identifier" column="_identifier" type="java.lang.Long" unsaved-value="null">
<generator class="hilo"><param name="table">_hibernate_unique_key_181</param></generator>
</id>
<many-to-one cascade="persist,merge,save-update" class="com.genia.toolbox.model.association.one_to_one_bidi.impl.DriverOneToOneBidiImpl" name="driverInternal" column="_driver" unique="true"/>
</class>
</hibernate-mapping>
the following query:
FROM com.genia.toolbox.model.association.one_to_one_bidi.DriverOneToOneBidi AS a2, com.genia.toolbox.model.association.one_to_one_bidi.CarOneToOneBidi AS a3 WHERE ((a2.carInternal)=(a3))
failed with an exception:
left and right hand sides of a binary logic operator were incompatibile
This is due to the call to the method mutateRowValueConstructorSyntaxesIfNecessary of BinaryLogicOperatorNode.
One of the type is a OneToOneType which returns 0 for getColumnSpan while the other is a ManyToOneType that returns 1. The two values are not equal and an exception is thrown.
I join to this issue the relevant classes and mappings.
--
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
16 years, 5 months
[Hibernate-JIRA] Created: (HHH-3389) HQL generates wrong sql when using subquery on the same table
by Roman Makowski (JIRA)
HQL generates wrong sql when using subquery on the same table
-------------------------------------------------------------
Key: HHH-3389
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3389
Project: Hibernate3
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.6
Reporter: Roman Makowski
I've got following insert in my code:
String queryString = "INSERT INTO Regg (index, code) "
+ "SELECT ( SELECT cast(count(*) - 1 as int) "
+ " FROM Code c2 "
+ " WHERE c2.parent.id = c1.parent.id AND c2.id <= c1.id), c1.code "
+ "FROM Code c1 "
+ "WHERE c1.parent.id = :DIM_ID";
Query q = session.createQuery(queryString);
q.setParameter(DIM_ID, dimId, Hibernate.LONG);
q.executeUpdate();
Unfortunately HQLQueryPlan returns following SQL query to the database:
insert into REG_G ( C_SEQ, C_VALUE )
select (
select cast(count(*)-1 as int)
from REG_CODE code1_
where code1_.C_DIM_ID=REG_CODE.C_DIM_ID and code1_.C_ID<=REG_CODE.C_ID) as col_0_0_,
code0_.C_CODE as col_1_0_
from REG_CODE code0_
where code0_.C_DIM_ID=?
where REG_CODE.C_DIM_ID and REG_CODE.C_ID are not resolved to code0_.C_DIM_ID and code0_.C_ID
--
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
16 years, 5 months
[Hibernate-JIRA] Created: (HHH-3398) _BackRef issue in Parent Child relation while inserting both records in one table (Recursive Relation)
by Vivek Sharma (JIRA)
_BackRef issue in Parent Child relation while inserting both records in one table (Recursive Relation)
-------------------------------------------------------------------------------------------------------
Key: HHH-3398
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3398
Project: Hibernate3
Issue Type: Bug
Environment: Hibernate 3.0
MS SQL Server
Reporter: Vivek Sharma
Hi, I am new to hibernate and seems to be stuck in resolving this _backref issue. I have come across many parent child relation issues in forum but nowhere , I was able to find the scenerio where parent and child records are being inserted in the same table. That, is self refering table.
First, I can not attach my test case as, I am working for a Investment Banking solution and sending of code is prohibited. So, I will try to put the identical scenerio here...
I have a Leg which can have numerous Legs inside it. Thats, is Leg -> Leg -> Leg
Now my class Leg.java is defined as below:
public class Leg implements Serializable
{
protected long id;
protected Leg parentLeg;
protected Set<Leg> legs;
protected String name;
<!--- further getter and setter for the same is defined -->
}
My hbm looks like this:
<class name="Leg" table="tblLeg">
<id name="idLeg">
<generator class="native" />
</id>
<!-- Mapping Set<leg> attribute of the parent entity Leg -->
<set name="legs" cascade="all" lazy="false" fetch="join"
inverse="true">
<key column="idParentLeg" />
<one-to-many class="Leg" />
</set>
<many-to-one name="idParentLeg" class="Leg">
<column name="idParentLeg" />
</many-to-one>
<property name="name"/>
</class>
Now, i am inserting records inside the table using the following approach:
Leg parentLeg = new Leg();
parentLeg.setName("Parent Leg");
parentLeg.setParentLeg(null);
Leg childLeg = new Leg();
childLeg.setName("Child Leg");
childLeg.setParentLeg(parentLeg); // i am setting back referencing here
childLeg.setLegs(null); // child has no child elements
Set setLeg = new HashSet();
setLeg.add(childLeg);
parentLeg.setLegs(setLeg); // adding child elements to parent leg
// this is how I am saving it in my test case:
return (Long) getHibernateTemplate().save(entity);
But when i do this, the parent leg is inserted successfully and after it throws the following stack trace:
com.rbs.tradeservice.services.exception.ServiceException: com.rbs.tradeservice.services.exception.ServiceException: org.springframework.dao.DataIntegrityViolationException: not-null property references a null or transient value: com.rbs.tradeservice.jaxb.Leg._legsBackref; nested exception is org.hibernate.PropertyValueException: not-null property references a null or transient value: com.rbs.tradeservice.jaxb.Leg._legsBackref
at com.rbs.tradeservice.util.LoggingAroundAdvice.invoke(LoggingAroundAdvice.java:83)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:143)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:619)
at com.rbs.tradeservice.services.tradeservice.impl.TradeDomainModelServiceImpl$$EnhancerByCGLIB$$cc0b0bf6.saveTradeDetails(<generated>)
at com.rbs.tradeservice.services.tradeservice.impl.TradeDomainModelServiceImplTest.testSave(TradeDomainModelServiceImplTest.java:65)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Any help would be really appreciated... Someone suggested me to upgrade it to highre version to resolve this issue...
--
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
16 years, 5 months
[Hibernate-JIRA] Created: (HV-67) Referencing method from an older version of Hibernate Core
by Miroslav Havram (JIRA)
Referencing method from an older version of Hibernate Core
----------------------------------------------------------
Key: HV-67
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-67
Project: Hibernate Validator
Issue Type: Bug
Components: validators
Affects Versions: 3.1.0.CR1
Environment: Hibernate Core 3.3.0.GA
Hibernate Annotations 3.4.0.CR2
Reporter: Miroslav Havram
Method getSource from an older version of the Hibernate Core is referenced.
It is stated within the compatibility matrix that Hibernate Validator 3.1.0.CR1 is compatible only with Hibernate Core 3.3.x version(s).
Exception in thread "main" java.lang.NoSuchMethodError: org.hibernate.event.PreInsertEvent.getSource()Lorg/hibernate/engine/SessionImplementor;
at org.hibernate.validator.event.ValidateEventListener.onPreInsert(ValidateEventListener.java:172)
at org.hibernate.action.EntityInsertAction.preInsert(EntityInsertAction.java:178)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:72)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:365)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)
--
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
16 years, 5 months