-->
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: Cross-Reference Table insertion problem
PostPosted: Sat Jun 16, 2007 10:08 pm 
Newbie

Joined: Sat Jun 16, 2007 5:41 pm
Posts: 1
Location: Colorado Springs
Hibernate version: 3.1
Database: MySQL

I'm improving a database and giving it a front end for an orchestra and as such I have 3 tables: Music, Note, MusicNotes

So I have a many-to-one relationship from Music to MusicNotes and a many-to-one relationship from Note to MusicNotes.

I used MyEclipse to do some code generation for me. The hbm files are as follows:
Music:
Code:
<class name="Music" table="music" catalog="ppp">
        <id name="musicId" type="java.lang.Integer">
            <column name="MusicId" />
            <generator class="native"></generator>
        </id>
        <property name="title" type="java.lang.String">
            <column name="Title" length="50" />
        </property>
        <property name="composerId" type="java.lang.Integer">
            <column name="ComposerId" />
        </property>
        <set name="musicnoteses" inverse="true">
            <key>
                <column name="MusicId" not-null="true" />
            </key>
            <one-to-many class="MusicNotes" />
        </set>
    </class>

Note:
Code:
<class name="Note" table="note" catalog="ppp">
        <id name="noteId" type="java.lang.Integer">
            <column name="NoteID" />
            <generator class="native"></generator>
        </id>
        <many-to-one name="notetype" class="NoteType" fetch="select">
            <column name="NoteType" length="50" />
        </many-to-one>
        <property name="note" type="java.lang.String">
            <column name="Note" />
        </property>
        <set name="musicnoteses" inverse="true">
            <key>
                <column name="NoteId" not-null="true" />
            </key>
            <one-to-many class="MusicNotes" />
        </set>
    </class>

MusicNotes:
Code:
<class name="MusicNotes" table="musicnotes" catalog="ppp">
        <composite-id name="id" class="MusicNotesId">
            <key-many-to-one name="note" class="Note">
                <column name="NoteId" />
            </key-many-to-one>
            <key-many-to-one name="music" class="Music">
                <column name="MusicId" />
            </key-many-to-one>
        </composite-id>
    </class>


Log4J (should be showing DEBUG, ERROR):
Code:
2007-06-16 20:00:00,703 DEBUG [MusicNotesDAO] - saving MusicNotes instance
2007-06-16 20:00:00,703 DEBUG [org.springframework.orm.hibernate3.SessionFactoryUtils] - Opening Hibernate Session
2007-06-16 20:00:00,703 DEBUG [org.hibernate.impl.SessionImpl] - opened session at timestamp: 4841658780479488
2007-06-16 20:00:00,703 DEBUG [org.hibernate.event.def.DefaultSaveOrUpdateEventListener] - saving transient instance
2007-06-16 20:00:00,703 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] - generated identifier: component[note,music]{music=Music#9, note=Note#8}, using strategy: org.hibernate.id.Assigned
2007-06-16 20:00:00,703 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] - saving [org.ppp.MusicLibrary.data.domain.MusicNotes#component[note,music]{music=Music#9, note=Note#8}]
2007-06-16 20:00:00,703 DEBUG [MusicNotesDAO] - save successful


When I call the DAO and save a Music object everything inserts fine. When I call the DAO and save a Note object everything inserts fine as well. However, when I call the DAO on the MusicNotes save it doesn't do anything. There are no messages in the logs, there are no errors that are triggered. Nothing happens.

I found a post on an issue with key-many-to-one and tried to implement it but I get:

org.hibernate.PropertyNotFoundException: field not found: ...

I've searched all over for an answer but haven't been able to find anything yet. So, what have I done wrong? Thanks in advanced for the help.


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.