-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Problem with HQL INSERT used with IdClass
PostPosted: Mon Feb 19, 2007 1:37 pm 
Newbie

Joined: Thu Mar 31, 2005 5:01 pm
Posts: 16
I have the following classes:
Code:
@Entity
@IdClass(APK.class)
public class A {

   @Id
   int id;
}

and
Code:
public class APK implements Serializable{
   
   int id;
}

and
Code:
@Entity
public class B {

   @Id
   int id;
}


Hibernate 3.2.2 has a problem parsing the following HQL:
Code:
insert into A (id) select b.id from B b


Here is the exception I see:
Code:
Caused by: org.hibernate.QueryException: can only generate ids as part of bulk insert with either sequence or post-insert style generators [insert into A (id) select b.id from com.medq.platform.persistence.ejb.entitymanager.example.B b]
   at org.hibernate.hql.ast.HqlSqlWalker.postProcessInsert(HqlSqlWalker.java:622)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.insertStatement(HqlSqlBaseWalker.java:491)
   at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:253)
   at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:228)
   at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160)
   at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
   at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
   at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
   at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
   at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
   at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
   at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)


The problem seems to be caused by org.hibernate.hql.ast.tree.IntoClause.visitPropertySpecNodes:
Code:
      if ( name.equals( persister.getIdentifierPropertyName() ) ) {
         explicitIdInsertion = true;
      }


getIdentifierPropertyName returns null when IdClass is used, so Hibernate thinks I am not explicitly setting IDs.

This looks like a bug to me. Is it?


Top
 Profile  
 
 Post subject: Any solution?
PostPosted: Mon Jun 23, 2008 4:48 pm 
Newbie

Joined: Mon Jun 23, 2008 4:43 pm
Posts: 1
Did you find any solution?
I'm with the same problem, and didn't find nothing useful in google.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 24, 2008 2:59 am 
Newbie

Joined: Mon Sep 19, 2005 3:08 am
Posts: 19
I Used SQLQery and it works with it.


Top
 Profile  
 
 Post subject: Re: Problem with HQL INSERT used with IdClass
PostPosted: Wed Mar 27, 2013 12:25 pm 
Beginner
Beginner

Joined: Mon Apr 04, 2011 12:08 pm
Posts: 32
hi,
that issue is still not resolved in hibernate 3.6.3

what i would like is to obtain the key of a mapped bean, no matter if it's @Id @EmbeddedId or @IdClass
and i can't find a way other than implementing that myself


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.