-->
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: SQLServerException with many-to-many mapping.
PostPosted: Fri Jul 24, 2009 12:49 pm 
Newbie

Joined: Fri Jul 24, 2009 12:29 pm
Posts: 3
Hello,

I face a very strange Problem here. I've got 3 tables. 2 of them linked to the third one as a many-to-many collection:

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 24.07.2009 17:47:28 by Hibernate Tools 3.2.4.GA -->
<hibernate-mapping>
    <class name="com.YYYY.XXXX.mopad2009.data.TKolonne" table="T_KOLONNE" schema="dbo" catalog="XXXX_DATA">
        <id name="IPkKolonne" type="java.lang.Integer">
            <column name="I_PK_KOLONNE" />
            <generator class="identity"></generator>
        </id>
        <property name="SBeschreibung" type="string">
            <column name="S_BESCHREIBUNG" length="50" />
        </property>
        <set name="TAuftragszeiles" inverse="true" lazy="true" table="T_AUFTRAGSZEILE" fetch="select">
            <key>
                <column name="I_PK_KOLONNE" not-null="true" />
            </key>
            <one-to-many class="com.YYYY.XXXX.mopad2009.data.TAuftragszeile" />
        </set>
        <set name="TRessources" inverse="false" lazy="true" table="T_KOLONNE_RESSOURCE" fetch="select">
            <key>
                <column name="I_PK_KOLONNE" not-null="true" />
            </key>
            <many-to-many entity-name="com.netzlink.XXXX.mopad2009.data.TRessource">
                <column name="I_PK_RESSOURCE" not-null="true" />
            </many-to-many>
        </set>
        <set name="TMitarbeiters" inverse="false" lazy="true" table="T_KOLONNE_MITARBEITER" fetch="select">
            <key>
                <column name="I_PK_KOLONNE" not-null="true" />
            </key>
            <many-to-many entity-name="com.YYYY.XXXX.mopad2009.data.TMitarbeiter">
                <column name="I_PK_MITARBEITER" not-null="true" />
            </many-to-many>
        </set>
    </class>
</hibernate-mapping>


Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 24.07.2009 17:47:28 by Hibernate Tools 3.2.4.GA -->
<hibernate-mapping>
    <class name="com.YYYY.XXXX.mopad2009.data.TMitarbeiter" table="T_MITARBEITER" schema="dbo" catalog="XXXX_DATA">
        <id name="IPkMitarbeiter" type="java.lang.Integer">
            <column name="I_PK_MITARBEITER" />
            <generator class="identity"></generator>
        </id>
        <property name="SName" type="string">
            <column name="S_NAME" length="59" />
        </property>
        <property name="SVorname" type="string">
            <column name="S_VORNAME" length="50" />
        </property>
        <property name="SKuerzel" type="string">
            <column name="S_KUERZEL" length="10" />
        </property>
        <set name="TKolonnes" inverse="true" lazy="true" table="T_KOLONNE_MITARBEITER" fetch="select">
            <key>
                <column name="I_PK_MITARBEITER" not-null="true" />
            </key>
            <many-to-many entity-name="com.YYYY.XXXX.mopad2009.data.TKolonne">
                <column name="I_PK_KOLONNE" not-null="true" />
            </many-to-many>
        </set>
        <set name="TTaetigkeitsnachweises" inverse="true" lazy="true" table="T_TAETIGKEITSNACHWEIS" fetch="select">
            <key>
                <column name="I_PK_MITARBEITER" not-null="true" />
            </key>
            <one-to-many class="com.YYYY.XXXX.mopad2009.data.TTaetigkeitsnachweis" />
        </set>
    </class>
</hibernate-mapping>


Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 24.07.2009 17:47:28 by Hibernate Tools 3.2.4.GA -->
<hibernate-mapping>
    <class name="com.YYYY.XXXX.mopad2009.data.TRessource" table="T_RESSOURCE" schema="dbo" catalog="XXXX_DATA">
        <id name="IPkRessource" type="java.lang.Integer">
            <column name="I_PK_RESSOURCE" />
            <generator class="identity"></generator>
        </id>
        <property name="SBezeichnung" type="string">
            <column name="S_BEZEICHNUNG" length="50" />
        </property>
        <set name="TTankbelegs" inverse="true" lazy="true" table="T_TANKBELEG" fetch="select">
            <key>
                <column name="I_PK_RESSOURCE" not-null="true" />
            </key>
            <one-to-many class="com.YYYY.XXXX.mopad2009.data.TTankbeleg" />
        </set>
        <set name="TRessourceTaetigkeits" inverse="true" lazy="true" table="T_RESSOURCE_TAETIGKEIT" fetch="select">
            <key>
                <column name="I_PK_RESSOURCE" not-null="true" />
            </key>
            <one-to-many class="com.YYYY.XXXX.mopad2009.data.TRessourceTaetigkeit" />
        </set>
        <set name="TKolonnes" inverse="true" lazy="true" table="T_KOLONNE_RESSOURCE" fetch="select">
            <key>
                <column name="I_PK_RESSOURCE" not-null="true" />
            </key>
            <many-to-many entity-name="com.YYYY.XXXX.mopad2009.data.TKolonne">
                <column name="I_PK_KOLONNE" not-null="true" />
            </many-to-many>
        </set>
    </class>
</hibernate-mapping>


Everytime I try to access the T_MITARBEITER table I get this exception:

Quote:
2009-07-24 18:34:31,488 WARN [org.hibernate.util.JDBCExceptionReporter] - <SQL Error: 208, SQLState: S0002>
2009-07-24 18:34:31,488 ERROR [org.hibernate.util.JDBCExceptionReporter] - <Ungültiger Objektname 'dbo.T_KOLONNE_MITARBEITER'.>


So it tries to tell me, that the T_KOLONNE_MITARBEITER table does not exist. But it exists in the database. When I execute the sql code generated by hibernate in sql query analyzer, it works fine. I can access the TRessource objects without any problems. Setting the hibernate.default_schema property to "dbo" didn't help either. Both tables have full access for schema dbo set. As soon as hibernate and jdbc are involved it doesn't work.

Server is MS SQL 2005.

Thanks in advance for any help

Frank


Top
 Profile  
 
 Post subject: Re: SQLServerException with many-to-many mapping.
PostPosted: Mon Jul 27, 2009 8:42 am 
Newbie

Joined: Fri Jul 24, 2009 12:29 pm
Posts: 3
fha wrote:
Hello,

I face a very strange Problem here. I've got 3 tables. 2 of them linked to the third one as a many-to-many collection:


Noone on this?

Update: I changed the many-to-many mappings in two many-to-one mapping with the mapping table as another object. Now it works. Has anyone else observed this behaviour on SQL Server in combination with Hibernate?


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.