[hibernate-issues] [Hibernate-JIRA] Resolved: (HHH-3400) hql insert doesn't work when inserting into a table with composite-id
Gail Badner (JIRA)
noreply at atlassian.com
Sun Aug 17 18:42:39 EDT 2008
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3400?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Gail Badner resolved HHH-3400.
------------------------------
Assignee: Gail Badner
Resolution: Rejected
Please use the user forum (http://forum.hibernate.org/) for help.
> hql insert doesn't work when inserting into a table with composite-id
> ---------------------------------------------------------------------
>
> Key: HHH-3400
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3400
> Project: Hibernate3
> Issue Type: Bug
> Components: query-hql
> Affects Versions: 3.2.6
> Environment: 3.2.6GA, any database
> Reporter: Ning Zhang
> Assignee: Gail Badner
>
> I have a table serving as an association table, so the Id of the table is just the ids from the linked tables. The mapping file looks like:
> <class name="UserPt" table="user_pt" >
> <composite-id>
> <key-property name="userId" type="java.lang.Long" column="user_id"/>
> <key-property name="ptId" type="java.lang.Long" column="pt_id"/>
> </composite-id>
> </class>
> And I need to run some HQL to insert the association into the table like:
> INSERT INTO UserPt(userId, ptId) SELECT user.id, pt.id FROM...........
> Because of the complicated logic we have in the FROM statement, we cannot do this just by using collection mapping. When I run this HQL, it gives an error saying:
> "can only generate ids as part of bulk insert with either sequence or post-insert style generators".
> It looks like the hibernate is think the id is not set. I have tried different approaches like creating an separate id class, setting "mapped" to true, etc. But none of it solve the problem. The only thing I can do is defining a fake id in the hibernate mapping, which may introduce some problem in the future.
> I would appreciate if someone can fix this issue or having some better work around for it. Thanks a lot.
--
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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list