-->
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.  [ 3 posts ] 
Author Message
 Post subject: Mapping two object attributes to one column in a table.
PostPosted: Mon May 01, 2006 2:54 pm 
Newbie

Joined: Tue Jun 07, 2005 10:46 am
Posts: 15
I am wondering if it is possible to map two attributes of an object,(in this case GeneBiomarker.id and GeneBiomarker.geneSymbol) to a single column in a database which also happens to be a primary key. When I first tried this I got an error telling me i needed to set the property geneSymbol element insert="false and update="false". After doing so I got a similar message regarding the "id" attribute. So I made that insert=false and update=false as well. At that point hibernate complains about the dtd for "id" not having an insert or update element as shown below:

May 1, 2006 2:30:55 PM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: gov/nih/nci/caintegrator/findings/GeneBiomarker.hbm.xml
May 1, 2006 2:30:55 PM org.hibernate.util.XMLHelper$ErrorLogger error
SEVERE: Error parsing XML: XML InputStream(7) Attribute "insert" must be declared for element type "id".
May 1, 2006 2:30:55 PM org.hibernate.util.XMLHelper$ErrorLogger error
SEVERE: Error parsing XML: XML InputStream(7) Attribute "update" must be declared for element type "id".

My database is read only, so updating is not an issue.

I could add a duplicate column in my database, but the customer isn't too exciited about that. Any thoughts would be appeciated.

Thanks,

Mike


Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.0.2

Mapping documents:

<hibernate-mapping package="gov.nih.nci.caintegrator.findings">
<class name="GeneBiomarker" table="GENE_BIOMARKER" lazy="true" polymorphism="explicit">
<id name="id" type="java.lang.String" column="GENE_SYMBOL">
<generator class="assigned" />
</id>
<property name="geneSymbol" type="java.lang.String" column="GENE_SYMBOL" insert="false" update="false" />
<many-to-one name="bioMarkerAnnotation" class="gov.nih.nci.caintegrator.findings.GeneAnnotation" column="GENE_SYMBOL" lazy="true" />
</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:
oracle 9i
The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

_________________
M Connolly


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 01, 2006 3:14 pm 
Expert
Expert

Joined: Tue Apr 25, 2006 12:04 pm
Posts: 260
Try to change the insert and update attributes also on many-to-one

Code:
<hibernate-mapping package="gov.nih.nci.caintegrator.findings">
  <class name="GeneBiomarker"
            table="GENE_BIOMARKER" lazy="true"   
            polymorphism="explicit">
       <id name="id"
           type="java.lang.String"
           column="GENE_SYMBOL">
           <generator class="assigned" />
       </id>
      <property name="geneSymbol"
                type="java.lang.String"
                column="GENE_SYMBOL"
                insert="false"
                update="false" />
       <many-to-one name="bioMarkerAnnotation"
                    class="gov.nih.nci.caintegrator.findings.GeneAnnotation"
                    column="GENE_SYMBOL"
                    lazy="true"
                    insert="false"
                    update="false"  />
  </class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 01, 2006 3:54 pm 
Newbie

Joined: Tue Jun 07, 2005 10:46 am
Posts: 15
Thanks man. That worked.

_________________
M Connolly


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.