-->
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.  [ 2 posts ] 
Author Message
 Post subject: Column appears twice - Hibernate generated prepared statemnt
PostPosted: Wed Oct 21, 2009 3:32 pm 
Newbie

Joined: Sat Oct 17, 2009 7:34 am
Posts: 9
Hi,

Here are my hibernate mappings:
Code:
   
<class name="ie.admin.details.`Person" table="Person">
      <id name="personID" column="PERSON_ID" type="string">
           <!-- Chapter 5 of Hibernate Reference PDF for MySQL Auto increment fields -->
          <generator class="identity"/>
      </id>
     
      ...properties listed here...
     
       <list name="photos"    cascade="all" lazy="false">
          <key column="person_id" not-null="true" />
          <list-index column="file_id"/>
          <one-to-many class="ie.admin.details.UploadedFile"/>
        </list>
  </class>
 
 
 
   <class name="ie.admin.details.UploadedFile" table="MEDIA">
        <id name="file_id" column="FILE_ID" type="string">
            <!-- Chapter 5 of Hibernate Reference PDF for MySQL Auto increment fields -->
            <generator class="identity"/>
        </id>

        <property name="person_id" column="PERSON_ID" type="string"/>
        ...Other properties listed here...

   </class>


The error I get is that Hibernate generates the following prepared statement:
insert into MEDIA (PERSON_ID, FILE_TYPE, FILE_LOCATION, ORDER_NUM, TITLE, person_id, file_id) values (?, ?, ?, ?, ?, ?, ?)
Notice how PERSON_ID appears twice

I changed it so PERSON_ID to be upper case in all places. Hibernate just falls over at the point of loading its XML files then.
i tried insert="false". Hibernate does not like this either. In fact I get a message before I even compile
Attribute "insert" must be declared for element type "one-to- many".

I am using Hibernate 3.3.1
Please help I have this error for the last few days and no matter what i do I cant fix it

Thanks


Top
 Profile  
 
 Post subject: Re: Column appears twice - Hibernate generated prepared statemnt
PostPosted: Wed Oct 21, 2009 4:47 pm 
Newbie

Joined: Sat Oct 17, 2009 7:34 am
Posts: 9
<property name="person_id" column="PERSON_ID" type="string" insert="true" update="true"/>

in <class name="ie.gymlockr.admin.details.UploadedFile" table="MEDIA">
works

can someone explain what insert="true" update="true" do?


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