-->
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.  [ 1 post ] 
Author Message
 Post subject: Specifying a table alias to avoid column name colision
PostPosted: Tue Mar 11, 2008 4:00 pm 
Newbie

Joined: Fri Oct 12, 2007 12:23 pm
Posts: 9
Greetings!

I'm using the table-per-subclass mapping strategy using <joined-subclass>, and found that in one case, the parent and child table have a column with the same name.

Here's what the database looks like:

ParentDocument
-------
id
column1

ChildDocument
------
id
parentId
column2

I'm trying to get the child "id" field to use in a set mapping.
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.company.project.module.domain">
    <joined-subclass name="ChildDocument" extends="com.company.project.module.domain.ParentDocument" dynamic-update="true" table="ChildDocument">
        <key column="parentId" />

        <set name="roles" table="DocumentRoles">
            <key column="childDocumentId" property-ref="????" />
            <many-to-many column="roleId" class="com.company.project.module.domain.Role" />
        </set>
    </joined-subclass>
</hibernate-mapping>


I've tried putting all the following in ????, but to no avail:
    id
    ChildDocument.id
    Document0_1_.id (examined the produced SQL to get this)
    {ChildDocument}.id
    {ChildDocument.id}


Unfortunately, I don't have the ability to change column names or else I would have done that hours ago. I would appreciate any help, as I seem to have hit a wall :)
-- Corey


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

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.