[Hibernate-JIRA] Created: (HHH-2710) Cannot specify on-delete="cascade" for a map or a set with just one element
by Gerald Klopp (JIRA)
Cannot specify on-delete="cascade" for a map or a set with just one element
---------------------------------------------------------------------------
Key: HHH-2710
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2710
Project: Hibernate3
Issue Type: Improvement
Components: core
Affects Versions: 3.2.4
Reporter: Gerald Klopp
Priority: Minor
I'd like to specify the on-delete="cascade" attribute for a map or for a set with just one element.
When I try to do this, I get the following exception :
Initial SessionFactory creation failed.org.hibernate.MappingException: only inverse one-to-many associations may use on-delete="cascade"
The on-delete="cascade" attribute can be specified for more complex relationships like one-to-many. But it seems that the case of a simple map or set is not covered.
- Mapping document example:
<hibernate-mapping>
<class name="Document" table="DOCUMENT">
<id name="id" column="DOCUMENT_ID">
<generator class="native" />
</id>
<map name="titles" table="DOCUMENT_TITLE" lazy="false">
<key column="DOCUMENT_ID" on-delete="cascade" />
<index column="LANGUAGE" type="string" />
<element column="TITLE" type="text" not-null="true" />
</map>
<set name="references" table="DOCUMENT_REFERENCE" lazy="false">
<key column="DOCUMENT_ID" on-delete="cascade" />
<element type="string" column="REFERENCE" />
</set>
</class>
</hibernate-mapping>
- Exception stack trace :
Initial SessionFactory creation failed.org.hibernate.MappingException: only inverse one-to-many associations may use on-delete="cascade": Document.references
Exception in thread "main" java.lang.ExceptionInInitializerError
at fr.gklopp.test.hibernate3.util.HibernateUtil.<clinit>(HibernateUtil.java:17)
at fr.gklopp.test.hibernate3.simple.DocumentManager.createAndStoreDocument(DocumentManager.java:23)
at fr.gklopp.test.hibernate3.simple.DocumentManager.main(DocumentManager.java:68)
Caused by: org.hibernate.MappingException: only inverse one-to-many associations may use on-delete="cascade": fr.gklopp.test.hibernate3.simple.Document.references
at org.hibernate.mapping.Collection.validate(Collection.java:267)
at org.hibernate.mapping.Set.validate(Set.java:19)
at org.hibernate.cfg.Configuration.validate(Configuration.java:1106)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1287)
at fr.gklopp.test.hibernate3.util.HibernateUtil.<clinit>(HibernateUtil.java:13)
... 2 more
- Database : Oracle 10
--
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
13 years, 9 months
[Hibernate-JIRA] Created: (HHH-2587) There is an attempt to set more parameters on a prepared statement than the latter can hold
by Zied Hamdi (JIRA)
There is an attempt to set more parameters on a prepared statement than the latter can hold
-------------------------------------------------------------------------------------------
Key: HHH-2587
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2587
Project: Hibernate3
Issue Type: Bug
Components: query-sql
Affects Versions: 3.2.3
Environment: JPA through hibernate
Reporter: Zied Hamdi
Priority: Blocker
Attachments: IntoCore.zip
You can directly import the zip content into netBeans 5.5 the just launch: the test is executed at the home page servlet call.
I have an index that doesn't exist : 11 (the total count of columns is 10) :
Hibernate: insert into BasicPersonArchiveEntry (endDate, entryPerformer_revision, entryPerformer_id, lastOccurence, note, startDate, source_revision, source_id, revision, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
could not bind value '0' to parameter: 11; Invalid argument: parameter index 11 is out of range.
SQL Error: -99999, SQLState: null
Invalid argument: parameter index 11 is out of range.
Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: could not insert: [com.homeservices.model.impl.BasicPersonArchiveEntry]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2267)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2660)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:52)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
at org.hibernate.ejb.AbstractEntityManagerImpl$1.beforeCompletion(AbstractEntityManagerImpl.java:516)
at com.sun.enterprise.distributedtx.J2EETransaction.commit(J2EETransaction.java:395)
at com.sun.enterprise.distributedtx.J2EETransactionManagerOpt.commit(J2EETransactionManagerOpt.java:357)
at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:3653)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:3431)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1247)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:192)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:118)
at $Proxy49.create(Unknown Source)
at tests.entities.TestArchiveServlet.processRequest(TestArchiveServlet.java:46)
at tests.entities.TestArchiveServlet.doGet(TestArchiveServlet.java:61)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:397)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:278)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:179)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:73)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:182)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
at com.sun.enterprise.web.VirtualServerPipeline.invoke(VirtualServerPipeline.java:120)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:137)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.web.connector.grizzly.ProcessorTask.invokeAdapter(ProcessorTask.java:667)
at com.sun.enterprise.web.connector.grizzly.ProcessorTask.processNonBlocked(ProcessorTask.java:574)
at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:844)
at com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:287)
at com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:212)
at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:252)
at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:75)
Caused by: org.apache.derby.client.am.SqlException: Invalid argument: parameter index 11 is out of range.
at org.apache.derby.client.am.PreparedStatement.checkForValidParameterIndex(Unknown Source)
at org.apache.derby.client.am.PreparedStatement.checkSetterPreconditions(Unknown Source)
at org.apache.derby.client.am.PreparedStatement.setLong(Unknown Source)
at org.hibernate.type.LongType.set(LongType.java:42)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:136)
at org.hibernate.type.NullableType.nullSafeSet(NullableType.java:116)
at org.hibernate.type.ComponentType.nullSafeSet(ComponentType.java:284)
at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2008)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2243)
... 46 more
EJB5018: An exception was thrown during an ejb invocation on [ArchivableFacadeStatelessBean]
javax.ejb.EJBException: Transaction aborted; nested exception is: javax.transaction.RollbackException: Transaction marked for rollback.
--
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
13 years, 10 months
[Hibernate-JIRA] Created: (HHH-2460) Multiple object creates on HQL select causes "unexpected token: ,"
by Steve Mayhew (JIRA)
Multiple object creates on HQL select causes "unexpected token: ,"
------------------------------------------------------------------
Key: HHH-2460
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2460
Project: Hibernate3
Type: Bug
Components: query-hql
Versions: 3.1.2
Environment: MySQL
Reporter: Steve Mayhew
When executing this query:
select new java.lang.String('test1'), new java.lang.String('test2')
from SomeMappedClass
You get a syntax error. It does not matter what is in the from clause, result is always the same.
[2007-03-01 16:51:29,349] [ERROR:org.hibernate.hql.PARSER] [] - line 1:37: unexpected token: ,
[2007-03-01 16:51:29,365] [DEBUG:org.hibernate.hql.ast.AST] [] - --- HQL AST ---
\-[QUERY] 'query'
org.hibernate.hql.ast.QuerySyntaxException: unexpected token: , near line 1, column 37 [select new java.lang.String('test1'), new java.lang.String('test2')
from SomeMappedClass
at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:244)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:155)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:109)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:75)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:54)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:134)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:113)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1602)
at net.jvnet.dev.hqe.ThreadHQLQueryExecution.run(Unknown Source)
Caused by: line 1:37: unexpected token: ,
at org.hibernate.hql.antlr.HqlBaseParser.selectFrom(HqlBaseParser.java:1145)
at org.hibernate.hql.antlr.HqlBaseParser.queryRule(HqlBaseParser.java:702)
at org.hibernate.hql.antlr.HqlBaseParser.selectStatement(HqlBaseParser.java:296)
at org.hibernate.hql.antlr.HqlBaseParser.statement(HqlBaseParser.java:159)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:238)
... 9 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
13 years, 10 months
[Hibernate-JIRA] Created: (HHH-3494) HQLQueryPlan gives back zero result for "getSingleResult()" although one result is available
by Christian Hofschroer (JIRA)
HQLQueryPlan gives back zero result for "getSingleResult()" although one result is available
--------------------------------------------------------------------------------------------
Key: HHH-3494
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3494
Project: Hibernate Core
Issue Type: Bug
Components: query-hql
Affects Versions: 3.3.1
Environment: 3.3.1.GA, hsqldb 1.8.0.7
Reporter: Christian Hofschroer
Attachments: patch.txt
I have run the following code snippets both and only the second one works, because there is a bug in HQLQueryPlan.
// This does not work correctly (query is javax.persistence.Query)
ExampleObject e = (ExampleObject) query.getSingleResult();
// Replacement with this code works
List l=query.getResultList() ;
assertEquals(1,l.size()) ;
ExampleObject e=(ExampleObject)l.get(0) ;
This problem occurs only in seldom cases when
1. Hibernate executes several sql queries and merges the result
and
2. There is a limit of results (the limit is "2" in version 3.3.1.GA, because only one result is expected anyway)
Attached is a patch for the class HQLQueryPlan. The line
if ( distinction.add( result ) ) {
has to be replaced with
if ( ! distinction.add( result ) ) {
In case the object was found it returns "true". With the current implementation the object is not added to "combinedResults" although it should be added.
It was not possible to reproduce the problem with the setup from "testsuite". If necessary I can provide a JUnit testcase.
--
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
13 years, 10 months
[Hibernate-JIRA] Created: (HHH-3121) Using fetch="subselect" and second level cache causes NullPointerException
by Adam Brod (JIRA)
Using fetch="subselect" and second level cache causes NullPointerException
--------------------------------------------------------------------------
Key: HHH-3121
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3121
Project: Hibernate3
Issue Type: Bug
Components: caching (L2)
Affects Versions: 3.2.6
Environment: Oracle 10g
Reporter: Adam Brod
I've been tuning some of our mappings to use fetch="subselect" to reduce the number of DB queries. However, I have run into two cases where I get the exception below. In both cases, I was loading a list of Videos, which are mapped to a list of other objects. (In this example, Media is the superclass of Video.) I apologize that I can't upload a full working example, but I will include the relevant mapping info.
<class name="Media" table="media" lazy="false" discriminator-value="0">
<cache usage="nonstrict-read-write"/>
<id name="id" column="id" type="long">
<generator class="seqhilo"><param name="sequence">hibernate_hi_sequence</param><param name="max_lo">500</param></generator>
</id>
...
<list name="tags" lazy="true" table="media_tags" cascade="save-update" fetch="subselect">
<cache usage="nonstrict-read-write"/>
<key column="media_id"/>
<list-index column="idx"/>
<many-to-many column="tag_id" class="com.brightcove.catalog.Tag"/>
</list>
...
<subclass name="Video" lazy="false" discriminator-value="1">
...
</subclass>
</class>
<class name="Tag" table="tag">
...
</class>
The HQL being executed is just a simple "from Video v where v.publisher_id = :pubId".
The line of code where the exception is generated in Video.getDTO() is accessing the Tags list:
for (Tag tag : getTags()) {
tags.add(tag.getDTO());
}
I've debugged into the Hibernate source to see where the NPE comes from (CollectionLoadContext line 298).
if ( persister.isVersioned() ) {
versionComparator = persister.getOwnerEntityPersister().getVersionType().getComparator();
final Object collectionOwner = getLoadContext().getPersistenceContext().getCollectionOwner( lce.getKey(), persister );
version = getLoadContext().getPersistenceContext().getEntry( collectionOwner ).getVersion(); //NPE!
}
It seems that "collectionOwner" is null, so calling getEntry(collectionOwner) returns null. Calling getVersion() on a null entry is what throws the NPE.
java.lang.NullPointerException
at org.hibernate.engine.loading.CollectionLoadContext.addCollectionToCache(CollectionLoadContext.java:298)
at org.hibernate.engine.loading.CollectionLoadContext.endLoadingCollection(CollectionLoadContext.java:256)
at org.hibernate.engine.loading.CollectionLoadContext.endLoadingCollections(CollectionLoadContext.java:222)
at org.hibernate.engine.loading.CollectionLoadContext.endLoadingCollections(CollectionLoadContext.java:195)
at org.hibernate.loader.Loader.endCollectionLoad(Loader.java:877)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:865)
at org.hibernate.loader.Loader.doQuery(Loader.java:729)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.loadCollectionSubselect(Loader.java:2066)
at org.hibernate.loader.collection.SubselectCollectionLoader.initialize(SubselectCollectionLoader.java:58)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:565)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1716)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:344)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
at org.hibernate.collection.AbstractPersistentCollection.readSize(AbstractPersistentCollection.java:109)
at org.hibernate.collection.PersistentList.size(PersistentList.java:91)
at com.brightcove.catalog.EconomicEntity.populateDTO(EconomicEntity.java:460)
at com.brightcove.catalog.Media.populateDTO(Media.java:192)
at com.brightcove.catalog.Video.populateDTO(Video.java:854)
at com.brightcove.catalog.Video.getDTO(Video.java:783)
at com.brightcove.catalog.Video.getDTO(Video.java:756)
--
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
13 years, 10 months