[Hibernate-JIRA] Created: (HV-53) AssertTrue and AssertFalse not compatible with null values
by benoit heinrich (JIRA)
AssertTrue and AssertFalse not compatible with null values
----------------------------------------------------------
Key: HV-53
URL: http://opensource.atlassian.com/projects/hibernate/browse/HV-53
Project: Hibernate Validator
Issue Type: Bug
Components: validators
Affects Versions: 3.0.0.ga
Reporter: benoit heinrich
The AssertTrue and AssertFalse validators do not work with null values, they actually generate a NullPointerException.
The code fix for this should be:
public class AssertFalseValidator implements Validator<AssertFalse>, Serializable {
public boolean isValid(Object value) {
if (value == null) return true; << this is the fix
return !(Boolean) value;
}
public void initialize(AssertFalse parameters) {
}
}
public class AssertTrueValidator implements Validator<AssertTrue>, Serializable {
public boolean isValid(Object value) {
if (value == null) return true; << this is the fix
return (Boolean) value;
}
public void initialize(AssertTrue parameters) {
}
}
Cheers,
/Benoit
--
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
17 years, 8 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
17 years, 8 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
17 years, 8 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
17 years, 8 months
[Hibernate-JIRA] Created: (HHH-3400) hql insert doesn't work when inserting into a table with composite-id
by Ning Zhang (JIRA)
hql insert doesn't work when inserting into a table with composite-id
---------------------------------------------------------------------
Key: HHH-3400
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3400
Project: Hibernate3
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.6
Environment: 3.2.6GA, any database
Reporter: Ning Zhang
I have a table serving as an association table, so the Id of the table is just the ids from the linked tables. The mapping file looks like:
<class name="UserPt" table="user_pt" >
<composite-id>
<key-property name="userId" type="java.lang.Long" column="user_id"/>
<key-property name="ptId" type="java.lang.Long" column="pt_id"/>
</composite-id>
</class>
And I need to run some HQL to insert the association into the table like:
INSERT INTO UserPt(userId, ptId) SELECT user.id, pt.id FROM...........
Because of the complicated logic we have in the FROM statement, we cannot do this just by using collection mapping. When I run this HQL, it gives an error saying:
"can only generate ids as part of bulk insert with either sequence or post-insert style generators".
It looks like the hibernate is think the id is not set. I have tried different approaches like creating an separate id class, setting "mapped" to true, etc. But none of it solve the problem. The only thing I can do is defining a fake id in the hibernate mapping, which may introduce some problem in the future.
I would appreciate if someone can fix this issue or having some better work around for it. Thanks a lot.
--
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
17 years, 8 months
[Hibernate-JIRA] Created: (HHH-3152) StaleStateException using many-to-many together with one-to-many
by Donatas Ciuksys (JIRA)
StaleStateException using many-to-many together with one-to-many
----------------------------------------------------------------
Key: HHH-3152
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3152
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.6
Environment: Hibernate EntityManager 3.3.1 GA, Hibernate Annotations 3.3.0 GA, Hibernate Core 3.2.6 GA.
DB2 9.5 (production), Derby 10.3.2.1 (reproducible test case)
Reporter: Donatas Ciuksys
Attachments: db_schema.gif, ManyToMany.zip
I have many-to-many association between tables A and B (via join table A_B, see attached db_schema.gif). Join table has additional data columns, so I represent it as entity AB and have two one-to-many associations (A <-> AB and B <-> AB, with cascade=Cascade.REMOVE). Also I have many-to-many association between A and B (joinColumns are marked with insertable=false, updatable=false, though the marking/unmarking doesn't change the behaviour).
Table A is modeled as abstract entity A that is inherited by two concrete entities ATrue and AFalse. Table A has column BOOL_PROP (boolean property) of type INTEGER. ATrue spans objects with BOOL_PROP being true (1), AFalse - being false (0), column BOOL_PROP is used as Discriminator column.
The problem: having in database several ATrue and AFalse entities, it is impossible to delete ATrue entity - StaleStateException is being thrown:
Code fragment (p.getAllTrueA() return list of ATrue entities):
em.getTransaction().begin();
em.remove(p.getAllTrueA().get(0));
em.getTransaction().commit();
Log and exception stack trace:
Hibernate: delete from A_B where A=?
2008-03-03 18:02:10,313 [main] DEBUG org.hibernate.type.IntegerType - binding '4' to parameter: 1
Hibernate: delete from ADMIN.A_B where ID=?
2008-03-03 18:02:10,403 [main] DEBUG org.hibernate.type.IntegerType - binding '4' to parameter: 1
2008-03-03 18:02:10,473 [main] ERROR org.hibernate.event.def.AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:61)
...
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:54)
at manytomany.Main.run(Main.java:30)
at manytomany.Main.main(Main.java:15)
Exception in thread "main" javax.persistence.RollbackException: Error while commiting the transaction
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:71)
at manytomany.Main.run(Main.java:30)
at manytomany.Main.main(Main.java:15)
Caused by: javax.persistence.OptimisticLockException: org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
at org.hibernate.ejb.AbstractEntityManagerImpl.wrapStaleStateException(AbstractEntityManagerImpl.java:654)
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:59)
... 2 more
Caused by: org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:61)
...
The problem is that after:
Hibernate: delete from A_B where A=?
following statement is being executed:
Hibernate: delete from ADMIN.A_B where ID=?
The first statement deletes child A_B rows belonging to parent A. The second tries to delete what is already deleted.
Why I think it is related to many-to-many association: if I comment many-to-many association fields and getters/setters, problem is gone.
Attached is Eclipse project (standard java application), Derby DDL scripts. Following steps are needed to reproduce the problem:
1. Adjust the classpath (specify correct path to Hibernate EntityManager and its dependencies, Derby 10.3 derbyclient.jar)
2. Adjust database URL in /src/META-INF/persistence.xml (I'm using absolute path to DB, that is located at the projects root)
3. Start Derby network server (or adjust database URL to use embedded driver)
4. Start the application - it tries to delete ATrue entity and fails.
You can recreated the database if you wish - projects root folder contains DB_DDL.sql scripts. The program checks, whether the DB is empty, and if so, first fills it up with test data, then exits. Restart it again - it will load some ATrue entities and will try to delete one.
--
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
17 years, 8 months