[Hibernate-JIRA] Created: (HHH-3884) NPE with mutable Natuarl Id's
by Michael Kopp (JIRA)
NPE with mutable Natuarl Id's
-----------------------------
Key: HHH-3884
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3884
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.2.2
Reporter: Michael Kopp
When saving an entity with a mutable natural id hibernate throws the following NPE.
java.lang.NullPointerException
at org.hibernate.engine.StatefulPersistenceContext.getNaturalIdSnapshot(StatefulPersistenceContext.java:267)
at org.hibernate.event.def.DefaultFlushEntityEventListener.checkNaturalId(DefaultFlushEntityEventListener.java:78)
at org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:162)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:113)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:196)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
I checked the code and found the reason:
- getNaturalIdSnapshot calls getDatabaseSnapshot and checks the result for NO_ROW but not for null
- getDatabaseSnapshot will never return NO_ROW but null if nothing was found
hence getNaturalIdSnapshot will produce a NPE if the entity is not in the database already.
the fix is simple:
change:
Object[] entitySnapshot = getDatabaseSnapshot( id, persister );
if ( entitySnapshot == NO_ROW ) {
return null;
}
to
Object[] entitySnapshot = getDatabaseSnapshot( id, persister );
if ( entitySnapshot == null ) {
return null;
}
This is still there in trunk as well!
--
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, 8 months
[Hibernate-JIRA] Created: (HHH-2041) Update with unaltered natural-id fails
by Jim Pease (JIRA)
Update with unaltered natural-id fails
--------------------------------------
Key: HHH-2041
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2041
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.1.3
Environment: hibernate-3.1.3, mysql-4.1.12
Reporter: Jim Pease
This may be a duplicate of http://opensource.atlassian.com/projects/hibernate/browse/HHH-1574.
Getting following error:
caused by: org.hibernate.HibernateException: immutable natural identifier of an instance of edu.syr.lsb.gmt.impl.LinkImpl was altered
at org.hibernate.event.def.DefaultFlushEntityEventListener.checkNaturalId(DefaultFlushEntityEventListener.java:80)
at org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:155)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:106)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:195)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
...
This is occurring without modifications to the natural identifier, which is mapped as follows:
<natural-id>
<property name="activityRef" column="ACTIVITY_REF" length="255" not-null="true" />
<many-to-one name="goal" class="GoalImpl" column="GOAL_ID" not-null="true" cascade="none" />
</natural-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
14 years, 8 months
[Hibernate-JIRA] Created: (HHH-4065) Incorrect SQL is used for HQL if the number of values for a filter collection parameter is changed
by Nicklas Nordborg (JIRA)
Incorrect SQL is used for HQL if the number of values for a filter collection parameter is changed
--------------------------------------------------------------------------------------------------
Key: HHH-4065
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4065
Project: Hibernate Core
Issue Type: Bug
Components: query-hql
Affects Versions: 3.3.2
Environment: Hibernate 3.3.2
Reporter: Nicklas Nordborg
Attachments: trace.txt
I think that maybe the fix for HHH-530 has introduced a problem with filters that has a collection-type parameter. If the number of parameters in that collection changes during the lifetime of a SessionFactory the SQL that is used becomes incorrect and either has too many or too few parameter placeholders (eg. '?') in the SQL. There was no problem in Hibernate 3.3.1. A typical error message is:
java.sql.SQLException: Parameter index out of bounds. 2 is not between valid values of 1 and 1
Below is some pseudo-code that shows what happens when the number of values in a collection is increased from 1 to 2. The 'memberOf' is a simple filter on the `id` column: `id` IN (:items)
String hql = "select n from NewsData n";
List idList = new ArrayList();
idList.add(1);
Session s = .... // create new session
s.enableFilter("memberOf").setParameterList("items", idList);
s.createQuery(hql).list();
// SQL: select .... `News` newsdata0_ where newsdata0_.`id` IN (?)
s.close();
idList.add(2);
s = ... // create new session
s.enableFilter("memberOf").setParameterList("items", idList);
s.createQuery(hql).list(); // <--- error here with 3.3.2 but works with 3.3.1
// SQL (3.3.2): select .... `News` newsdata0_ where newsdata0_.`id` IN (?)
// SQL (3.3.1): select .... `News` newsdata0_ where newsdata0_.`id` IN (?, ?)
I am attaching a file with TRACE-level output from both Hibernate 3.3.2 and 3.3.1. The relevant difference seems to be that in Hibernate 3.3.2 the query plan is cached with:
[SQL_TOKEN] SqlFragment: 'newsdata0_.`id` IN (?)'
but in Hibernate 3.3.1 with:
[SQL_TOKEN] SqlFragment: 'newsdata0_.`id` IN (:memberOf.items)'
--
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, 8 months
[Hibernate-JIRA] Created: (HHH-4909) Null Pointer Exception When Usding Spring 3.0 with Hibernate 3.5.0-Beta-x
by Petar Tahchiev (JIRA)
Null Pointer Exception When Usding Spring 3.0 with Hibernate 3.5.0-Beta-x
-------------------------------------------------------------------------
Key: HHH-4909
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4909
Project: Hibernate Core
Issue Type: Bug
Components: entity-manager
Affects Versions: 3.5.0-CR-1, 3.5.0-Beta-4, 3.5.0-Beta-3, 3.5.0-Beta-2, 3.5.0.Beta-1
Environment: Java, 1.6, Spring 3.0.0 (tested also with 3.0.1.SNAPSHOT)
Reporter: Petar Tahchiev
Priority: Critical
Attachments: stacktrace.txt
Hi guys,
I had an application working fine with OpenJPA, but I decided to migrate to Hibernate and I get a Null pointer exception (see the attached stacktrace).
Let me know if you need some other info. My configuration is below:
persistence.xml:
===========================================
===========================================
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="frontend-ui">
<class>com.fugsley.beech.betting.db.model.User</class>
.........[more here]...................
<!-- provider>org.hibernate.ejb.HibernatePersistence</provider>
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider-->
<properties>
<!-- OpenJPA configuration -->
<!-- property name="openjpa.ConnectionURL" value="jdbc:mysql://localhost:3306/fugsley?useUnicode=true&characterEncoding=UTF-8"/>
<property name="openjpa.ConnectionDriverName" value="com.mysql.jdbc.Driver"/>
<property name="openjpa.ConnectionUserName" value="fugsley"/>
<property name="openjpa.ConnectionPassword" value="r00tka"/>
<property name="openjpa.DetachState" value="DetachedStateField=true"/>
<property name="openjpa.Log" value="DefaultLevel=INFO, Tool=INFO"/> -->
<!-- configuration pool via c3p0-->
<property name="c3p0.acquire_increment" value="1"/>
<property name="c3p0.idle_test_period" value="100"/> <!-- seconds -->
<property name="c3p0.min_size" value="5"/>
<property name="c3p0.max_size" value="20"/>
<property name="c3p0.timeout" value="1800"/>
<property name="c3p0.max_statements" value="50"/>
<!-- Hibernate configuration -->
<property name="hibernate.archive.autodetection" value="class, hbm"/>
<property name="hibernate.show_sql" value="false"/>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.connection.password" value="r00tka"/>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/fugsley?useUnicode=true&characterEncoding=UTF-8"/>
<property name="hibernate.connection.username" value="fugsley"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.c3p0.min_size" value="5"/>
<property name="hibernate.c3p0.max_size" value="20"/>
<property name="hibernate.c3p0.timeout" value="300"/>
<property name="hibernate.c3p0.max_statements" value="50"/>
<property name="hibernate.c3p0.idle_test_period" value="3000"/>
</properties>
</persistence-unit>
</persistence>
===============spring-application-context===========================
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="loadTimeWeaver">
<bean
class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" />
</property>
<property name="dataSource" ref="beechDataSource" />
<property name="jpaVendorAdapter">
<bean
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="database" value="Mysql" />
<property name="showSql" value="false" />
</bean>
</property>
</bean>
--
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, 8 months
[Hibernate-JIRA] Created: (EJB-463) Merging of one-to-many relations not JPA spec compliant for lazy relations
by Dirk (JIRA)
Merging of one-to-many relations not JPA spec compliant for lazy relations
--------------------------------------------------------------------------
Key: EJB-463
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-463
Project: Hibernate Entity Manager
Issue Type: Bug
Affects Versions: 3.4.0.GA
Environment: Hibernate 3.2.6, Hibernate EntityManager 3.4.0, Hibernate Annotations 3.4.0, Oracle
Reporter: Dirk
Attachments: CascadeTest.zip
Topic has been posted to the Hibernate Forum. See https://forum.hibernate.org/viewtopic.php?f=1&t=999398
Summary:
Suppose you have an object Master with one-to-many relation to Detail.
@Entity
public class Master implements Serializable {
@OneToMany(mappedBy = "master", cascade={CascadeType.MERGE, CascadeType.PERSIST})
private List<Detail> details = new ArrayList<Detail>();
...
}
Master is loaded without fetching Detail (= lazy) and EntityManager is closed. Master is now in detached state. Merging Master causes Hibernate EntityManager to eagerly load the Detail collection although it is in lazy state. This is not JPA spec compliant.
JPA spec states: The persistence provider must not merge fields marked LAZY that have not been fetched: it must ignore
such fields when merging. See 3.2.4.1 Merging Detached Entity State, p.51.
Tested also with the latest version of EclipseLink. EclipseLink behaves as expected.
Testcase attached (Netbeans 6.7).
--
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, 8 months