-->
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.  [ 7 posts ] 
Author Message
 Post subject: one-to-many: doesnt insert turma_id
PostPosted: Sun May 30, 2004 3:31 pm 
Regular
Regular

Joined: Sat May 29, 2004 2:16 pm
Posts: 81
i'm using hibernate2.1, winXP Pro, MySql 4.0.12.
i read this from command line:

Hibernate: insert into detalhes (estrategia, id) values (?, ?)
but it should also insert (turma_id) !
my cfg.xml file:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
   <class name = "relatorio.Turma" table = "turmas">
      <id name = "id" column = "id" unsaved-value = "null">
         <generator class = "increment" />
      </id>
      <property name = "turma"       column = "turma" />
      <property name = "ano"          column = "ano" />
      <property name = "masculinos"    column = "masculinos" />
      <property name = "femininos"    column = "femininos" />
       <set name = "detalhe" inverse = "true" lazy = "true" cascade = "all">
           <key column = "turma_id" />
          <one-to-many class = "relatorio.Detalhe" />
       </set>
   </class>
</hibernate-mapping>

Can someone pls help me?
thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 30, 2004 3:36 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
you need an inverse <many-to-one> mapping if you use inverse="true"


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 30, 2004 3:43 pm 
Regular
Regular

Joined: Sat May 29, 2004 2:16 pm
Posts: 81
thanks for your answer

gavin wrote:
you need an inverse <many-to-one> mapping if you use inverse="true"

I dont understand what you mean
Can you pls explain a bit more?


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 30, 2004 4:02 pm 
Regular
Regular

Joined: Sat May 29, 2004 2:16 pm
Posts: 81
i made this:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
   <class name = "relatorio.Detalhe" table = "detalhes">
      <id name = "id" column = "id" unsaved-value = "null">
         <generator class = "increment" />
      </id>
      <property name = "estrategia" column = "estrategia" />
        <many-to-one name = "turma_id" column = "turma_id" class = "relatorio.Detalhe"
        cascade="all">
    </many-to-one>
   </class>
</hibernate-mapping>

but then i'm obliged to manually insert the turma_id, i guess...


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 30, 2004 4:07 pm 
Regular
Regular

Joined: Sat May 29, 2004 2:16 pm
Posts: 81
lol
i got back to my first settings, took off inverse=true and works!
i'm very happy!
can i get any trouble because of that?
tx once more


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 30, 2004 4:08 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Please read the documentation, "Example: Parent/child relationship".

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 30, 2004 4:19 pm 
Regular
Regular

Joined: Sat May 29, 2004 2:16 pm
Posts: 81
i will
thank you


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