[Hibernate-JIRA] Created: (HHH-3868) Merging transient entity with a component property with parent mapping causes NullPointerException
by Vinnie Luther (JIRA)
Merging transient entity with a component property with parent mapping causes NullPointerException
--------------------------------------------------------------------------------------------------
Key: HHH-3868
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3868
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.1, 3.2.6
Environment: Core 3.3.1.GA, Annotations 3.4.0.GA, HSQL 1.8, SQLServer2005
Reporter: Vinnie Luther
Attachments: TransientMergeComponentParent.zip
Merge a transient entity with a component mapping with a parent mapping causes
java.lang.NullPointerException
at org.hibernate.engine.StatefulPersistenceContext.proxyFor(StatefulPersistenceContext.java:693)
at org.hibernate.type.ComponentType.instantiate(ComponentType.java:515)
at org.hibernate.type.ComponentType.replace(ComponentType.java:482)
at org.hibernate.type.TypeFactory.replace(TypeFactory.java:538)
at org.hibernate.event.def.DefaultMergeEventListener.copyValues(DefaultMergeEventListener.java:429)
at org.hibernate.event.def.DefaultMergeEventListener.entityIsTransient(DefaultMergeEventListener.java:231)
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:170)
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:81)
at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:704)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:688)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:692)
at test.TransientMergeComponentParentTest.testTransientMergeComponentParent(TransientMergeComponentParentTest.java:31)
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 org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)
at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
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)
Removing @Parent mappings from component solved the problem. Attached is an eclipse project with demonstration minus the hibernate core 3.3.1, annotations 3.4.0 dependencies and hsqldb jar.
--
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, 12 months
[Hibernate-JIRA] Commented: (HHH-1661) merge of a deleted object results in a insert?
by Michael Grünewald (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1661?page=c... ]
Michael Grünewald commented on HHH-1661:
----------------------------------------
Hi, may be you should validate saveOrUpdate too.
Part of my JUNit-Test: (PostgreSql 8.2.x)
/* Runs on empty DB. Otherwise the assert-statements would be a little bit mor complex. */
[code]
for (int i = 0; i < 2; i++) {
s = HibernateUtil.openSession();
final int rows = listCriteriaAndEvictResults(s).size();
System.out.println("Exists? " + s.get(CountryModel.class, country.getId()));
s.close();
s = HibernateUtil.openSession();
t = s.beginTransaction();
// s.saveOrUpdate(country);
if (i == 0) {
s.save(country);
}
else {
country = (CountryModel) s.merge(country);
}
t.commit();
System.out.println("SAVED!");
s.close();
s = null;
s = HibernateUtil.openSession();
Assert.assertEquals(rows + 1, listCriteriaAndEvictResults(s).size(), 0);
s.close();
s = HibernateUtil.openSession();
t = s.beginTransaction();
s.delete(country);
t.commit();
System.out.println("DELETED!");
s.close();
s = HibernateUtil.openSession();
Assert.assertEquals(rows, listCriteriaAndEvictResults(s).size(), 0);
s.close();
}
[/code]
[code]
private List<Object> listCriteriaAndEvictResults(final Session s) {
final Criteria c = s.createCriteria(CountryModel.class);
final List<Object> list = c.list();
for (final Object o : list) {
s.evict(o);
}
return list;
}
[/code]
Cause with saveOrUpdate instead of the if-else-clause it throws an
"org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update" (foreign key), with merge it works and prints this output:
Exists? null
SAVED!
DELETED!
Exists? null
SAVED!
DELETED!
Even I'm not quite sure if the above exception, is really caused by this problem. But merge works. so it should be.
In other set-ups I also got:
org.hibernate.HibernateException: reassociated object has dirty collection reference (or an array)
org.hibernate.HibernateException: Found two representations of same collection:
and.
org.hibernate.HibernateException: reassociated object has dirty collection reference (or an array)
(e.g. with lock())
So merge shouldn't work, but saveOrUpdate should work instead. So cause the current behaviour is vice versa at the moment. You may should look at both methods.
May be that was the reason, why merge wasn't implemented that way it used to be.
By the way the extensive use of sessions was just to track down the real error cause.
Hope this piece of code fragment is enough to reproduce the problem.
Otherwise please ask for the rest of it. Even Countrymodel is a very complex class with a huge object tree.
Greetings Michael
> merge of a deleted object results in a insert?
> ----------------------------------------------
>
> Key: HHH-1661
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1661
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.1.3
> Environment: Hibernate 3.1.3, SQL Server
> Reporter: Tu-Thach
> Assignee: Gail Badner
>
> A persistent object is loaded from a session and deleted, then close the session. Using that same object in another session and call merge results in the object being inserted into the database. Here's the sample code:
> Session session = factory.getCurrentSession();
> session.beginTransaction();
> MyClass obj = (MyClass)session.load(MyClass.class, new Integer(10));
> session.delete(obj);
> session.getTransaction().commit();
> session = factory.getCurrentSession();
> session.beginTransaction();
> session.merge(obj);
> session.getTransaction().commit();
> Since the object is already deleted, merge could not find it and thus proceeds with a INSERT. Shouldn't it throw an exception instead?
--
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, 12 months
[Hibernate-JIRA] Created: (EJB-429) Wrong column type: COUNTRYCODE, expected: varchar2(4 char)
by Souvik Sutradhar (JIRA)
Wrong column type: COUNTRYCODE, expected: varchar2(4 char)
----------------------------------------------------------
Key: EJB-429
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-429
Project: Hibernate Entity Manager
Issue Type: Bug
Affects Versions: 3.2.1
Environment: eclips 3.4.1, Jboss 4.2.2 GA, Jboss Seam 2.1.1 GA
Reporter: Souvik Sutradhar
I'm using an Entity bean that look something like this...
@Entity
@Name("uibsCountry")
@Table(name = "UIBSCOUNTRIES", schema = "GHANATELFIXED", uniqueConstraints = {
@UniqueConstraint(columnNames = "COUNTRYCODE"),
@UniqueConstraint(columnNames = "COUNTRYDESC") })
public class Uibscountries implements java.io.Serializable {
........
........
@Column(name = "COUNTRYCODE", unique = true, nullable = false, length = 4)
@NotNull
@Length(max = 4)
public String getCountrycode() {
return this.countrycode;
}
..............
.............
In database column "COUNTRYCODE" is defined as char(4).
When i deploy the application the deployement fails because of this error:
javax.persistence.PersistenceException: org.hibernate.HibernateException: Wrong column type: COUNTRYCODE, expected: varchar2(4 char).
I can not change the datatype of the field...
Quick reply needed...
Thanks
--
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, 12 months
[Hibernate-JIRA] Created: (HHH-3844) Mapping Associations using composite-key element ,property-ref attribute and <formula> element
by Sandeep Vaid (JIRA)
Mapping Associations using composite-key element ,property-ref attribute and <formula> element
----------------------------------------------------------------------------------------------
Key: HHH-3844
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3844
Project: Hibernate Core
Issue Type: Improvement
Components: core
Environment: Hibernate 3.2.6.ga
Reporter: Sandeep Vaid
I want, join should be performed on 3 properties out of which 2 are normal properties and one is part of composite key.
How can i specify these 3 properties inside <properties> tag ?
<class name="Product" table="PRODUCT" optimistic-lock="version">
<id name="productId" column="PRODUCTID">
<generator class="assigned" />
</id>
<one-to-one name="productBasic" class="ProductBasic" cascade="save-update" property-ref="activeProduct">
<formula>'001'</formula>
<formula>TIMESTAMP ('9999-12-31 00:00:00.0')</formula>
<formula>PRODUCTID</formula>
</one-to-one>
</class>
<class name="ProductBasic" table="PRODUCTBASIC" optimistic-lock="version">
<composite-id name="compProductBasicBO" class="com.tietoenator.lis.db.impl.product.bo.CompProductBasicBO">
<key-property name="productId" column="PRODUCTID" ></key-property>
<key-property name="useType" column="USETYPE" ></key-property>
<key-property name="startTimeStamp" column="STARTTIMESTAMP" ></key-property>
</composite-id>
<properties name="activeProduct">
<!-- <property name="compProductBasicBO.useType" column="USETYPE" ></property> -->
<property name="endTimeStamp" column="ENDTIMESTAMP" ></property>
<many-to-one name="productBO" class="ProductBO" column="PRODUCTID" insert="false" update="false"/>
</properties>
</class>
--
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, 12 months
[Hibernate-JIRA] Commented: (HHH-1657) hql update generate wrong sql with joined subclass hierarcy
by Hany Philemon (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1657?page=c... ]
Hany Philemon commented on HHH-1657:
------------------------------------
If I had time and knowlege of hibernate internals I would have fought to fix it myself. Doing simple update and delete queries is a fundamenal task to many projects.
I wonder if anyone in Hibernate's team cares to fix this issue. More than 3 years has passed and the bug is still open. Currently 39 votes for this issue. What's the problem?
> hql update generate wrong sql with joined subclass hierarcy
> -----------------------------------------------------------
>
> Key: HHH-1657
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1657
> Project: Hibernate Core
> Issue Type: Bug
> Components: query-hql
> Environment: Hibernate 3.2.0cr1, Hibernate 3.1.3
> Reporter: Alexey Romanchuk
> Assignee: Gail Badner
>
> Let suppose that we have two joined subclass entities: Parent (id PK) and Child (id PK) that mapped with joined subclass method.
> When I try to update Child by id with hql:
> update Child c set c.field = 'value' where c.id = 1234
> hibernate generates joined tables like
> insert into HT_parent select child0_.id as id from child child0_ inner join parent child0_1_ on child0_.id=child0_1_.id wher id in = 1234
> look at last condition. hibernate use id WITH OUT tables alias that cause sql exception: column reference "id" is ambiguous
--
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, 12 months