[Hibernate-JIRA] Created: (HHH-2183) org.hibernate.LazyInitializationException: failed to lazily initialize a collection while using lazy set with key as property-ref in the mapping
by Artur Jonak (JIRA)
org.hibernate.LazyInitializationException: failed to lazily initialize a collection while using lazy set with key as property-ref in the mapping
------------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-2183
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2183
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.1.3
Environment: Oracle 9i
Reporter: Artur Jonak
Priority: Blocker
Attachments: hibernate-testcase.zip
I have an entity which can have multiple titles located in a separate table. I mapped this as a set where key attribute references other property of the entity:
<set name="titles" table="TTitle" cascade="none" lazy="true" inverse="true" mutable="false">
<key column="ID" property-ref="parentId"/>
<!--key column="ID"/-->
<element type="string" column="title"/>
</set>
when I try to display this set I get an exception:
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: test.lazysetinit.Record.titles, no session or session was closed
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358)
at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:343)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
...
The entire mapping is as follows:
<class name="Record" table="TRecord" mutable="false">
<id name="id" type="long">
<column name="ID" sql-type="number" length="12" not-null="true" unique="true"/>
</id>
<set name="titles" table="TTitle" cascade="none" lazy="true" inverse="true" mutable="false">
<key column="ID" property-ref="parentId"/>
<!--key column="ID"/-->
<element type="string" column="title"/>
</set>
<join table="TRecordInfo" inverse="true" fetch="join" optional="false">
<key column="ID"/>
<property name="parentId" not-null="false" />
<property name="status" />
</join>
</class>
Attached the test case: test.lazysetinit.LazySetInitTest. DB schema is located in test/conf/lazysetinit/schema.sql
Regards,
Artur
--
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, 8 months
[Hibernate-JIRA] Created: (HHH-2453) Inserting BIT to PostgreSQL table
by Imran M Yousuf (JIRA)
Inserting BIT to PostgreSQL table
---------------------------------
Key: HHH-2453
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2453
Project: Hibernate3
Type: Bug
Components: query-sql
Environment: Not sure about the hibernate version but will add it soon, downloaded last June. PostrgreSQL 8.2.3 on RedHat Fedora Core 1. Spring Framework.
Reporter: Imran M Yousuf
Attachments: CallUser.hbm.xml, hibernate_pgsql.properties
I created a Table which has a column active as Boolean in the entity and the HBM file specifies the type as boolean. When I use this configuration with MySQL it works fine, but when I use it with PostgreSQL I get an javax.sql.BatchUpdateException. so later I changed the HBM file 'active' column type to 'yes_no' and than it works fine. So I confirmed that the problem is due to the BIT(1) column.
So I next tried to manually insert into the column and it PgSQL tells that 1 needs to be casted. Please let me know if I can help in other ways, I will be most grateful to help.
Thank you,
Imran
--
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, 8 months
[Hibernate-JIRA] Created: (HHH-2523) informix 10 BLOB type
by Nick Airey (JIRA)
informix 10 BLOB type
---------------------
Key: HHH-2523
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2523
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.1
Environment: Hibernate 3.2.1
Informix Dynamic Server 10.00.FC5W4
IBM Informix JDBC Driver for IBM Informix Dynamic Server 3.00.JC2
Reporter: Nick Airey
Priority: Minor
Attachments: Informix10Dialect.java
Informix 10.0 and driver 3.0 supports the BLOB type, however the hibernate dialect file does not have this type registered.
Options for fixing would be to modify the existing InformixDialect, or (better) extend to a new class as per code snippet below, which is working fine for me.
package additional.hibernate;
import java.sql.Types;
import org.hibernate.dialect.InformixDialect;
/**
* @author Nick Airey
*/
public class Informix10Dialect extends InformixDialect {
public Informix10Dialect() {
super();
// register support for BLOB type in informix 10
registerColumnType( Types.BLOB, "blob" );
}
}
--
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, 8 months
[Hibernate-JIRA] Created: (HHH-2155) mysql dialect should not generate automatically index for foreign key
by Anthony Patricio (JIRA)
mysql dialect should not generate automatically index for foreign key
---------------------------------------------------------------------
Key: HHH-2155
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2155
Project: Hibernate3
Type: Improvement
Components: core
Environment: MySQL
Reporter: Anthony Patricio
Priority: Minor
Attachments: patch-mysqlDialect.txt
MySQLDialect.getAddForeignKeyConstraintString(String, String[], String, String[], boolean) method is generating also index which is not wanted.
Here is the modified method:
public String getAddForeignKeyConstraintString(
String constraintName,
String[] foreignKey,
String referencedTable,
String[] primaryKey, boolean referencesPrimaryKey
) {
String cols = StringHelper.join(", ", foreignKey);
return new StringBuffer(30)
//.append(" add index ")
//.append(constraintName)
//.append(" (")
//.append(cols)
//.append("), add constraint ")
.append(" add constraint ")
.append(constraintName)
.append(" foreign key (")
.append(cols)
.append(") references ")
.append(referencedTable)
.append(" (")
.append( StringHelper.join(", ", primaryKey) )
.append(')')
.toString();
}
--
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, 8 months
[Hibernate-JIRA] Created: (HHH-2610) Invalid SQL generation for dynamic filter
by Calin Pavel (JIRA)
Invalid SQL generation for dynamic filter
-----------------------------------------
Key: HHH-2610
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2610
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.3
Environment: Windows XP, database MS-SQL and MySQL, Hibernate 3.2.3
Reporter: Calin Pavel
I have a simple object model composed from three classes with their relationship as described above by mapping file. One of them is the superclass for the other two, and I have defined a filter for it. If filter is activated and try to retrieve an instance of subclass, generated SQL is invalid and an exception is thrown (see logs below).
Hibernate: 3.2.3
DB: MySQL 5.0.27, MS-SQL 2000, ...
Mappings:
<hibernate-mapping>
<class name="test.model.Entity" table="entity">
<id name="id" column="id" type="long">
<generator class="identity" />
</id>
<property name="siteId" type="string">
<column name="siteId" />
</property>
<joined-subclass name="test.model.User" table="user">
<key column="id" />
<property name="FirstName" type="string">
<column name="firstName" />
</property>
<property name="LastName" type="string">
<column name="lastName" />
</property>
<one-to-one name="Account" property-ref="User" cascade="delete" />
</joined-subclass>
<joined-subclass name="test.model.Account" table="account">
<key column="id" />
<property name="name" type="string">
<column name="name" />
</property>
<many-to-one name="User" column="user_id" class="test.model.User" unique="true" not-null="true" />
</joined-subclass>
<filter name="siteIdFilter" condition="siteId=:siteId" />
</class>
<filter-def name="siteIdFilter">
<filter-param name="siteId" type="string" />
</filter-def>
</hibernate-mapping>
Code:
Session session = HibernateUtils.currentSession();
session.enableFilter("siteIdFilter").setParameter("siteId", "opp");
User user = (User) session.get(User.class, new Long(3));
session.close();
Stacktrace:
11:18:16,475 DEBUG DefaultLoadEventListener:143 - loading entity: [test.model.User#3]
11:18:16,475 DEBUG DefaultLoadEventListener:290 - attempting to resolve: [test.model.User#3]
11:18:16,475 DEBUG DefaultLoadEventListener:326 - object not resolved in any cache: [test.model.User#3]
11:18:16,475 DEBUG BasicEntityPersister:2467 - Materializing entity: [test.model.User#3]
11:18:16,522 DEBUG EntityLoader:95 - Static select for entity test.model.User: select user0_.id as id1_, user0_1_.siteId as siteId0_1_, user0_.firstName as firstName1_1_, user0_.lastName as lastName1_1_, account1_.id as id0_, account1_1_.siteId as siteId0_0_, account1_.name as name2_0_, account1_.user_id as user3_2_0_ from user user0_ inner join entity user0_1_ on user0_.id=user0_1_.id left outer join account account1_ on user0_.id=account1_.user_id and account1_1_.siteId=:siteIdFilter.siteId left outer join entity account1_1_ on account1_.id=account1_1_.id where user0_.id=?
11:18:16,522 DEBUG Loader:1340 - loading entity: [test.model.User#3]
11:18:16,522 DEBUG AbstractBatcher:290 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
11:18:16,522 DEBUG SQL:324 - select user0_.id as id1_, user0_1_.siteId as siteId0_1_, user0_.firstName as firstName1_1_, user0_.lastName as lastName1_1_, account1_.id as id0_, account1_1_.siteId as siteId0_0_, account1_.name as name2_0_, account1_.user_id as user3_2_0_ from user user0_ inner join entity user0_1_ on user0_.id=user0_1_.id left outer join account account1_ on user0_.id=account1_.user_id and account1_1_.siteId=? left outer join entity account1_1_ on account1_.id=account1_1_.id where user0_.id=?
Hibernate: select user0_.id as id1_, user0_1_.siteId as siteId0_1_, user0_.firstName as firstName1_1_, user0_.lastName as lastName1_1_, account1_.id as id0_, account1_1_.siteId as siteId0_0_, account1_.name as name2_0_, account1_.user_id as user3_2_0_ from user user0_ inner join entity user0_1_ on user0_.id=user0_1_.id left outer join account account1_ on user0_.id=account1_.user_id and account1_1_.siteId=? left outer join entity account1_1_ on account1_.id=account1_1_.id where user0_.id=?
11:18:16,522 DEBUG AbstractBatcher:378 - preparing statement
11:18:16,553 DEBUG StringType:59 - binding 'opp' to parameter: 1
11:18:16,553 DEBUG LongType:59 - binding '3' to parameter: 2
11:18:16,569 DEBUG AbstractBatcher:298 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
11:18:16,569 DEBUG AbstractBatcher:416 - closing statement
11:18:16,569 DEBUG JDBCExceptionReporter:63 - could not load an entity: [test.model.User#3] [select user0_.id as id1_, user0_1_.siteId as siteId0_1_, user0_.firstName as firstName1_1_, user0_.lastName as lastName1_1_, account1_.id as id0_, account1_1_.siteId as siteId0_0_, account1_.name as name2_0_, account1_.user_id as user3_2_0_ from user user0_ inner join entity user0_1_ on user0_.id=user0_1_.id left outer join account account1_ on user0_.id=account1_.user_id and account1_1_.siteId=:siteIdFilter.siteId left outer join entity account1_1_ on account1_.id=account1_1_.id where user0_.id=?]
java.sql.SQLException: Unknown column 'account1_1_.siteId' in 'on clause'
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2928)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1571)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1666)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2994)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:936)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1030)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:120)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1272)
at org.hibernate.loader.Loader.doQuery(Loader.java:391)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1345)
at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:116)
at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:101)
at org.hibernate.persister.entity.BasicEntityPersister.load(BasicEntityPersister.java:2471)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:351)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:332)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:113)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:167)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:79)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:621)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:614)
at test.FilterMain.runMain2(FilterMain.java:47)
at test.FilterMain.main(FilterMain.java:33)
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:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
11:18:16,569 WARN JDBCExceptionReporter:71 - SQL Error: 1054, SQLState: 42S22
11:18:16,569 ERROR JDBCExceptionReporter:72 - Unknown column 'account1_1_.siteId' in 'on clause'
11:18:16,569 INFO DefaultLoadEventListener:85 - Error performing load command
org.hibernate.exception.SQLGrammarException: could not load an entity: [test.model.User#3]
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:70)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1359)
at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:116)
at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:101)
at org.hibernate.persister.entity.BasicEntityPersister.load(BasicEntityPersister.java:2471)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:351)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:332)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:113)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:167)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:79)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:621)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:614)
at test.FilterMain.runMain2(FilterMain.java:47)
at test.FilterMain.main(FilterMain.java:33)
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:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
Caused by: java.sql.SQLException: Unknown column 'account1_1_.siteId' in 'on clause'
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2928)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1571)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1666)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2994)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:936)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1030)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:120)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1272)
at org.hibernate.loader.Loader.doQuery(Loader.java:391)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1345)
... 17 more
11:18:16,584 DEBUG JDBCContext:322 - after autocommit
org.hibernate.exception.SQLGrammarException: could not load an entity: [test.model.User#3]
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:70)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1359)
at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:116)
at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:101)
at org.hibernate.persister.entity.BasicEntityPersister.load(BasicEntityPersister.java:2471)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:351)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:332)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:113)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:167)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:79)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:621)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:614)
at test.FilterMain.runMain2(FilterMain.java:47)
at test.FilterMain.main(FilterMain.java:33)
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:324)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
Caused by: java.sql.SQLException: Unknown column 'account1_1_.siteId' in 'on clause'
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2928)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1571)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1666)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2994)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:936)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1030)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:120)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1272)
at org.hibernate.loader.Loader.doQuery(Loader.java:391)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.loadEntity(Loader.java:1345)
... 17 more
--
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, 8 months
[Hibernate-JIRA] Created: (ANN-606) Annotation Validation: @Immutable annotation does not throw error or warning on usage on subclass
by Paul Singleton Kossler (JIRA)
Annotation Validation: @Immutable annotation does not throw error or warning on usage on subclass
--------------------------------------------------------------------------------------------------
Key: ANN-606
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-606
Project: Hibernate Annotations
Issue Type: Bug
Components: binder, documentation
Affects Versions: 3.3.0.ga
Environment: Hibernate3, Annotations.3.3.0
Reporter: Paul Singleton Kossler
The @Immutable annotation does not throw a configuration error when used on a subclass. The action required depends upon the decision in a bug/patch request for adding mutable=false to subclasses. In the current rule set the Mapping Schema for pre annotations is leveraged to define the legallity of declaring a mapped object Immutable. Base/Root classes allowed, child classes of Mutable=true not allowed, in either case the mutability of an object is directly dependent upon the mutability of the root mapped object in the object hierarchy.
The following documentation sources do not mention the issue in relation to the @Immutable annotation:
* online/down-loadable Hibernate-Annotations
* Java Persistence with Hibernate (ISBN: 1-932394-88-5)
If the rules outlined above are accurate or not: A validation error or warning should be thrown from Configuration during the loading of an incorrectly mapped class. The current method is to check the Annotations at bind time, and only at the "correct" location. This meta-rule validation should occur during the binding of a mapping to the Configuration, quickly indicating an error. Using the "older" xml based mapping this occurs when the schema (xsd) validates the mapping file (xml).
--
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, 8 months