-->
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: Mapping many-to-one in legacy schema
PostPosted: Tue Feb 22, 2011 1:49 am 
Newbie

Joined: Tue Feb 22, 2011 1:00 am
Posts: 1
Hi. I am trying to map a many-to-one from A.this to B.that without much luck.
The tables look like this:

Code:
create table A (
  id int not null,
  this int not null,
);
CREATE UNIQUE INDEX A_KEY ON A (id);

create table B (
  id2 varchar(30) not null,
  that int not null,
);
CREATE UNIQUE INDEX B_KEY ON B (id2);



And the mapping files look like this:
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">
<!-- Generated 17-Feb-2011 15:54:36 by Hibernate Tools 3.3.0.GA -->
<hibernate-mapping>
    <class name="A" table="A" schema="dbo">
        <cache usage="read-only"/>
       
        <id name="id" type="int">
            <column name="id" />
            <generator class="assigned"/>
        </id>
        <property name="this" type="int" insert="false" update="false">
            <column name="this" not-null="true" />
        </property>
        <many-to-one name="B" class="B" column="this" />
    </class>
</hibernate-mapping>




<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 17-Feb-2011 19:45:39 by Hibernate Tools 3.3.0.GA -->
<hibernate-mapping>
    <class name="B" table="B" schema="dbo">
        <cache usage="read-only"/>

        <id name="id2" type="string">
            <column name="id2" length="30" />
            <generator class="assigned"></generator>
        </id>
        <property name="that" type="int">
            <column name="that" not-null="true" />
        </property>
    </class>
</hibernate-mapping>



(The names have been changed so the fact there is a property called 'this' does not matter)

I know the mapping above is incorrect but how would I map it correctly?

How would I tell hibernate that A.this column maps to B.that? THere doesnt seem to be an obvious way to do this.

I have looked at docs and examples but it is still not clear how this can be mapped.

Any help would be greatly appreciated.

Thanks in advance.


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.