-->
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: Map a one to many where the key is different type int-string
PostPosted: Sun Dec 05, 2004 5:21 am 
Senior
Senior

Joined: Sat Jul 17, 2004 5:16 pm
Posts: 143
In the container the primary key is an int. In the many side, the foreign key is a String. Any way this will work with a mapping in Hibernate?

Hibernate version:
2
Mapping documents:
Code:
     <!-- in this table the key is an int -->

       <id name="pennId" column="PENN_ID" unsaved-value="0">
        <generator class="assigned"/>
      </id>

      <set name="pcadminGaBlobsFastSet">
        <key column="blob_person_id"/>  <!-- here it is a string -->
        <one-to-many class="PcadminGaBlob"/>
      </set>


Code:
    <class name="PcadminGaBlob" table="GA_BLOB_SIMPLE_V">
      <id name="rowId" column="prod_ROWID" unsaved-value="UNSAVED_VALUE">
        <generator class="assigned"/>
      </id>
      <!-- this is a string -->
      <property name="pennId" column="BLOB_PERSON_ID" />

    </class>

Full stack trace of any exception that occurs:

ORA-01722: invalid number (meaning the view is expecting a string, and we are sending a number)

Name and version of the database you are using:

Oracle 9i

The generated SQL (show_sql=true):

Code:
select pcadmingab0_.prod_ROWID as prod_ROWID__, pcadmingab0_.blob_person_id as blob_per5___, pcadmingab0_.prod_ROWID as prod_ROWID0_, pcadmingab0_.BLOB_PERSON_ID as BLOB_PER2_0_, pcadmingab0_.IMAGE_VERSION as IMAGE_VE3_0_, pcadmingab0_.SEGMENT_NUM as SEGMENT_4_0_ from GA_BLOB_SIMPLE_V pcadmingab0_ where pcadmingab0_.blob_person_id=10021368


In a perfect world, I could change the type in the DB, but legacy data and I cant touch it, and simply making a view where the type changes doesnt work. I guess I could just query explicitly for it and not auto grab...

Thanks,
Chris


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.