-->
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.  [ 11 posts ] 
Author Message
 Post subject: problem with composite keys?
PostPosted: Thu Feb 19, 2004 5:21 pm 
Newbie

Joined: Thu Feb 19, 2004 5:12 pm
Posts: 6
Hi, I just started using hibernate and am using Middlegen to connect to my database and generate my hbm config files for my tables. Now some tables are working and i get data just fine but on a few tables that have composite keys i'm having problems it seems.

Any Ideas?

My database is oracle 9i by the way, im using hibernate 2.1.2

here is the code i'm executing.
Code:
            List hosts = session.find("from Host");
            for (int i = 0; i < hosts.size(); i++)
            {
                Host host =  (Host) hosts.get(i);
            }


Here is the error message i'm getting
Code:
INFO  - building session factory
INFO  - no JNDI name configured
Hibernate: select host0_.HOST_ID as HOST_ID, host0_.AFFILIATE_ID as AFFILIAT2_, host0_.APP as APP, host0_.BG_COLOR as BG_COLOR, host0_.BG_IMAGE as BG_IMAGE, host0_.PRODUCT_DISCOUNT as PRODUCT_6_, host0_.SHIP_DISCOUNT_TYPE as SHIP_DIS7_, host0_.SHIP_DISCOUNT_AMT as SHIP_DIS8_, host0_.PAGE_HEADER as PAGE_HEA9_, host0_.PRIMARY_URL as PRIMARY10_, host0_.CART_LINK as CART_LINK, host0_.SHIP_TO_STORE as SHIP_TO12_, host0_.FONT_COLOR as FONT_COLOR, host0_.FONT_NAME as FONT_NAME, host0_.BORDER_COLOR as BORDER_15_, host0_.SHOW_UNAVAILABLE as SHOW_UN16_ from affiliate.HOST host0_
Hibernate: select affiliate0_.AFFILIATE_ID as AFFILIAT1_0_, affiliate0_.NAME as NAME0_, affiliate0_.ORDER_NOTIFICATION_EMAIL as ORDER_NO3_0_, affiliate0_.CUSTOMER_COMM_EMAIL as CUSTOMER4_0_, affiliate0_.VENDOR_CUST_ID as VENDOR_C5_0_, affiliate0_.FTP_ID as FTP_ID0_, affiliate0_.SHIP_METHOD as SHIP_MET7_0_, affiliate0_.GIFT_MSG as GIFT_MSG0_, affiliate0_.STATUS as STATUS0_ from affiliate.AFFILIATE affiliate0_ where affiliate0_.AFFILIATE_ID=?
net.sf.hibernate.UnresolvableObjectException: No row with the given identifier exists: 1, of class: com.muze.sphynx.affiliate.hibernate.Affiliate
   at net.sf.hibernate.UnresolvableObjectException.throwIfNull(UnresolvableObjectException.java:38)
   at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1918)
   at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:68)
   at net.sf.hibernate.type.EntityType.resolveIdentifier(EntityType.java:215)
   at net.sf.hibernate.type.ComponentType.resolveIdentifier(ComponentType.java:389)
   at net.sf.hibernate.type.ComponentType.nullSafeGet(ComponentType.java:145)
   at net.sf.hibernate.type.ManyToOneType.hydrate(ManyToOneType.java:60)
   at net.sf.hibernate.type.ComponentType.hydrate(ComponentType.java:371)
   at net.sf.hibernate.type.ComponentType.nullSafeGet(ComponentType.java:145)
   at net.sf.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:352)
   at net.sf.hibernate.loader.Loader.doQuery(Loader.java:203)
   at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
   at net.sf.hibernate.loader.Loader.doList(Loader.java:950)
   at net.sf.hibernate.loader.Loader.list(Loader.java:941)
   at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:834)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1512)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1491)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1483)
   at Tester.main(Tester.java:26)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:41)
   at java.lang.reflect.Method.invoke(Method.java:386)
   at com.intellij.rt.execution.application.AppMain.main(Unknown Source)
Process terminated with exit code 0


here is the hbm for one of my tables
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>
<!--
    Created by the Middlegen Hibernate plugin

    http://boss.bekk.no/boss/middlegen/
    http://hibernate.sourceforge.net/
-->

<class
    name="com.muze.sphynx.affiliate.hibernate.Host"
    table="HOST"
>
    <meta attribute="class-description" inherit="false">
       @hibernate.class
        table="HOST"
    </meta>

    <composite-id>
        <meta attribute="class-description" inherit="false">
           @hibernate.id
            generator-class="assigned"
        </meta>
        <key-property
            name="hostId"
            column="HOST_ID"
            type="java.lang.Integer"
            length="9"
        >
            <meta attribute="field-description">
               @hibernate.property
                column="HOST_ID"
                length="9"
            </meta>
        </key-property>
        <!-- bi-directional many-to-one association to AffiliateApp -->
        <key-many-to-one
           name="affiliateApp"
           class="com.muze.sphynx.affiliate.hibernate.AffiliateApp"
       >
            <meta attribute="field-description">
               @hibernate.many-to-one
                column="AFFILIATE_ID""
            </meta>
            <meta attribute="field-description">
               @hibernate.many-to-one
                column="APP""
            </meta>
           <column name="AFFILIATE_ID" />
           <column name="APP" />
       </key-many-to-one>
    </composite-id>   

    <property
        name="bgColor"
        type="java.lang.String"
        column="BG_COLOR"
        length="30"
    >
        <meta attribute="field-description">
           @hibernate.property
            column="BG_COLOR"
            length="30"
        </meta>   
    </property>
    <property
        name="bgImage"
        type="java.lang.String"
        column="BG_IMAGE"
        length="255"
    >
        <meta attribute="field-description">
           @hibernate.property
            column="BG_IMAGE"
            length="255"
        </meta>   
    </property>
    <property
        name="productDiscount"
        type="java.math.BigDecimal"
        column="PRODUCT_DISCOUNT"
        not-null="true"
        length="11"
    >
        <meta attribute="field-description">
           @hibernate.property
            column="PRODUCT_DISCOUNT"
            length="11"
            not-null="true"
        </meta>   
    </property>
    <property
        name="shipDiscountType"
        type="java.lang.String"
        column="SHIP_DISCOUNT_TYPE"
        length="1"
    >
        <meta attribute="field-description">
           @hibernate.property
            column="SHIP_DISCOUNT_TYPE"
            length="1"
        </meta>   
    </property>
    <property
        name="shipDiscountAmt"
        type="java.math.BigDecimal"
        column="SHIP_DISCOUNT_AMT"
        length="11"
    >
        <meta attribute="field-description">
           @hibernate.property
            column="SHIP_DISCOUNT_AMT"
            length="11"
        </meta>   
    </property>
    <property
        name="pageHeader"
        type="java.lang.String"
        column="PAGE_HEADER"
        length="75"
    >
        <meta attribute="field-description">
           @hibernate.property
            column="PAGE_HEADER"
            length="75"
        </meta>   
    </property>
    <property
        name="primaryUrl"
        type="java.lang.String"
        column="PRIMARY_URL"
        length="100"
    >
        <meta attribute="field-description">
           @hibernate.property
            column="PRIMARY_URL"
            length="100"
        </meta>   
    </property>
    <property
        name="cartLink"
        type="java.lang.String"
        column="CART_LINK"
        length="200"
    >
        <meta attribute="field-description">
           @hibernate.property
            column="CART_LINK"
            length="200"
        </meta>   
    </property>
    <property
        name="shipToStore"
        type="java.lang.String"
        column="SHIP_TO_STORE"
        length="1"
    >
        <meta attribute="field-description">
           @hibernate.property
            column="SHIP_TO_STORE"
            length="1"
        </meta>   
    </property>
    <property
        name="fontColor"
        type="java.lang.String"
        column="FONT_COLOR"
        length="30"
    >
        <meta attribute="field-description">
           @hibernate.property
            column="FONT_COLOR"
            length="30"
        </meta>   
    </property>
    <property
        name="fontName"
        type="java.lang.String"
        column="FONT_NAME"
        length="100"
    >
        <meta attribute="field-description">
           @hibernate.property
            column="FONT_NAME"
            length="100"
        </meta>   
    </property>
    <property
        name="borderColor"
        type="java.lang.String"
        column="BORDER_COLOR"
        length="30"
    >
        <meta attribute="field-description">
           @hibernate.property
            column="BORDER_COLOR"
            length="30"
        </meta>   
    </property>
    <property
        name="showUnavailable"
        type="int"
        column="SHOW_UNAVAILABLE"
        not-null="true"
        length="3"
    >
        <meta attribute="field-description">
           @hibernate.property
            column="SHOW_UNAVAILABLE"
            length="3"
            not-null="true"
        </meta>   
    </property>

    <!-- associations -->

</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 19, 2004 5:23 pm 
Newbie

Joined: Thu Feb 19, 2004 5:12 pm
Posts: 6
oops i posted the wrong error, that is a different error same deal though.

here is the correct one

Code:
"C:/Program Files/IBM/WebSphere Studio/Application Developer/v5.1/runtimes/base_v51/java\bin\java" -Dfile.encoding=windows-1252 -classpath "C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1\runtimes\base_v51\java\jre\lib\charsets.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1\runtimes\base_v51\java\jre\lib\core.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1\runtimes\base_v51\java\jre\lib\graphics.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1\runtimes\base_v51\java\jre\lib\jaws.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1\runtimes\base_v51\java\jre\lib\security.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1\runtimes\base_v51\java\jre\lib\server.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1\runtimes\base_v51\java\jre\lib\xml.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1\runtimes\base_v51\java\jre\lib\ext\activation.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1\runtimes\base_v51\java\jre\lib\ext\gskikm.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1\runtimes\base_v51\java\jre\lib\ext\ibmjcefips.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1\runtimes\base_v51\java\jre\lib\ext\ibmjceprovider.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1\runtimes\base_v51\java\jre\lib\ext\ibmjssefips.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1\runtimes\base_v51\java\jre\lib\ext\ibmorb.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1\runtimes\base_v51\java\jre\lib\ext\ibmpkcs11.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1\runtimes\base_v51\java\jre\lib\ext\ibmspnego.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1\runtimes\base_v51\java\jre\lib\ext\indicim.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1\runtimes\base_v51\java\jre\lib\ext\iwsorbutil.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1\runtimes\base_v51\java\jre\lib\ext\jaccess.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1\runtimes\base_v51\java\jre\lib\ext\JawBridge.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1\runtimes\base_v51\java\jre\lib\ext\jcert.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1\runtimes\base_v51\java\jre\lib\ext\jnet.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1\runtimes\base_v51\java\jre\lib\ext\jsse.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1\runtimes\base_v51\java\jre\lib\ext\ldapsec.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1\runtimes\base_v51\java\jre\lib\ext\log.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1\runtimes\base_v51\java\jre\lib\ext\mail.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1\runtimes\base_v51\java\jre\lib\ext\oldcertpath.jar;C:\Program Files\IBM\WebSphere Studio\Application Developer\v5.1\runtimes\base_v51\java\jre\lib\ext\PD.jar;C:\projects\hibernate affiliate\classes;C:\oracle\ora92\jdbc\lib\classes12.jar;C:\projects\stuff\hibernate-2.1\lib\swarmcache-1.0rc2.jar;C:\projects\stuff\hibernate-2.1\lib\jgroups-2.2.jar;C:\projects\stuff\hibernate-2.1\lib\cglib-2.0-rc2.jar;C:\projects\stuff\hibernate-2.1\lib\connector.jar;C:\projects\stuff\hibernate-2.1\lib\ehcache-0.6.jar;C:\projects\stuff\hibernate-2.1\lib\dom4j-1.4.jar;C:\projects\stuff\hibernate-2.1\lib\commons-dbcp-1.1.jar;C:\projects\stuff\hibernate-2.1\lib\log4j-1.2.8.jar;C:\projects\stuff\hibernate-2.1\lib\jboss-system.jar;C:\projects\stuff\hibernate-2.1\lib\xerces-2.4.0.jar;C:\projects\stuff\hibernate-2.1\lib\jboss-jmx.jar;C:\projects\stuff\hibernate-2.1\lib\commons-collections-2.1.jar;C:\projects\stuff\hibernate-2.1\lib\xml-apis.jar;C:\projects\stuff\hibernate-2.1\lib\xalan-2.4.0.jar;C:\projects\stuff\hibernate-2.1\lib\jaas.jar;C:\projects\stuff\hibernate-2.1\lib\ant-optional-1.5.3.jar;C:\projects\stuff\hibernate-2.1\lib\odmg-3.0.jar;C:\projects\stuff\hibernate-2.1\lib\c3p0-0.8.3.jar;C:\projects\stuff\hibernate-2.1\lib\junit-3.8.1.jar;C:\projects\stuff\hibernate-2.1\lib\commons-lang-1.0.1.jar;C:\projects\stuff\hibernate-2.1\lib\oscache-2.0.jar;C:\projects\stuff\hibernate-2.1\lib\commons-logging-1.0.3.jar;C:\projects\stuff\hibernate-2.1\lib\ant-1.5.3.jar;C:\projects\stuff\hibernate-2.1\lib\jboss-common.jar;C:\projects\stuff\hibernate-2.1\lib\proxool-0.8.3.jar;C:\projects\stuff\hibernate-2.1\lib\jta.jar;C:\projects\stuff\hibernate-2.1\lib\concurrent-1.3.2.jar;C:\projects\stuff\hibernate-2.1\lib\jboss-cache.jar;C:\projects\stuff\hibernate-2.1\lib\jcs-1.0-dev.jar;C:\projects\stuff\hibernate-2.1\lib\jdbc2_0-stdext.jar;C:\projects\stuff\hibernate-2.1\lib\commons-pool-1.1.jar;C:\projects\stuff\hibernate-2.1\hibernate2.jar;C:\projects\stuff\Middlegen-Hibernate-r4\build\gen-classes;C:\Program Files\IntelliJ-IDEA-4.0\lib\idea_rt.jar" -Didea.launcher.port=7593 "-Didea.launcher.library=C:\Program Files\IntelliJ-IDEA-4.0\bin\breakgen.dll" com.intellij.rt.execution.application.AppMain Tester
INFO  - Hibernate 2.1.2
INFO  - hibernate.properties not found
INFO  - using CGLIB reflection optimizer
INFO  - configuring from resource: /hibernate.cfg.xml
INFO  - Configuration resource: /hibernate.cfg.xml
INFO  - Mapping resource: com/muze/sphynx/affiliate/hibernate/Affiliate.hbm.xml
INFO  - Mapping class: com.muze.sphynx.affiliate.hibernate.Affiliate -> AFFILIATE
INFO  - Mapping resource: com/muze/sphynx/affiliate/hibernate/AffiliateApp.hbm.xml
INFO  - Mapping class: com.muze.sphynx.affiliate.hibernate.AffiliateApp -> AFFILIATE_APP
INFO  - Mapping resource: com/muze/sphynx/affiliate/hibernate/Anno.hbm.xml
INFO  - Mapping class: com.muze.sphynx.affiliate.hibernate.Anno -> ANNO
INFO  - Mapping resource: com/muze/sphynx/affiliate/hibernate/AnnoType.hbm.xml
INFO  - Mapping class: com.muze.sphynx.affiliate.hibernate.AnnoType -> ANNO_TYPE
INFO  - Mapping resource: com/muze/sphynx/affiliate/hibernate/Category.hbm.xml
INFO  - Mapping class: com.muze.sphynx.affiliate.hibernate.Category -> CATEGORY
INFO  - Mapping resource: com/muze/sphynx/affiliate/hibernate/Contact.hbm.xml
INFO  - Mapping class: com.muze.sphynx.affiliate.hibernate.Contact -> CONTACT
INFO  - Mapping resource: com/muze/sphynx/affiliate/hibernate/DiscountType.hbm.xml
INFO  - Mapping class: com.muze.sphynx.affiliate.hibernate.DiscountType -> DISCOUNT_TYPE
INFO  - Mapping resource: com/muze/sphynx/affiliate/hibernate/Host.hbm.xml
INFO  - Mapping class: com.muze.sphynx.affiliate.hibernate.Host -> HOST
INFO  - Mapping resource: com/muze/sphynx/affiliate/hibernate/HostUrl.hbm.xml
INFO  - Mapping class: com.muze.sphynx.affiliate.hibernate.HostUrl -> HOST_URL
INFO  - Mapping resource: com/muze/sphynx/affiliate/hibernate/Login.hbm.xml
INFO  - Mapping class: com.muze.sphynx.affiliate.hibernate.Login -> LOGIN
INFO  - Mapping resource: com/muze/sphynx/affiliate/hibernate/Selection.hbm.xml
INFO  - Mapping class: com.muze.sphynx.affiliate.hibernate.Selection -> SELECTION
INFO  - Mapping resource: com/muze/sphynx/affiliate/hibernate/SelectionType.hbm.xml
INFO  - Mapping class: com.muze.sphynx.affiliate.hibernate.SelectionType -> SELECTION_TYPE
INFO  - Configured SessionFactory: null
INFO  - processing one-to-many association mappings
INFO  - Mapping collection: com.muze.sphynx.affiliate.hibernate.Affiliate.contacts -> CONTACT
INFO  - Mapping collection: com.muze.sphynx.affiliate.hibernate.Affiliate.logins -> LOGIN
INFO  - Mapping collection: com.muze.sphynx.affiliate.hibernate.Affiliate.affiliateApps -> AFFILIATE_APP
INFO  - Mapping collection: com.muze.sphynx.affiliate.hibernate.AffiliateApp.annos -> ANNO
INFO  - Mapping collection: com.muze.sphynx.affiliate.hibernate.AffiliateApp.categories -> CATEGORY
INFO  - Mapping collection: com.muze.sphynx.affiliate.hibernate.AffiliateApp.selections -> SELECTION
INFO  - Mapping collection: com.muze.sphynx.affiliate.hibernate.AffiliateApp.hosts -> HOST
INFO  - Mapping collection: com.muze.sphynx.affiliate.hibernate.AnnoType.annos -> ANNO
INFO  - Mapping collection: com.muze.sphynx.affiliate.hibernate.SelectionType.selections -> SELECTION
INFO  - processing one-to-one association property references
INFO  - processing foreign key constraints
INFO  - Using dialect: net.sf.hibernate.dialect.Oracle9Dialect
INFO  - Use outer join fetching: true
INFO  - Using Hibernate built-in connection pool (not for production use!)
INFO  - Hibernate connection pool size: 20
INFO  - using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@ny01db202:1521:sphynx
INFO  - connection properties: {user=affiliate, password=affiliate}
INFO  - Transaction strategy: net.sf.hibernate.transaction.JDBCTransactionFactory
INFO  - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
INFO  - Use scrollable result sets: true
INFO  - Use JDBC3 getGeneratedKeys(): false
INFO  - Optimize cache for minimal puts: false
INFO  - Default schema set to: affiliate
INFO  - echoing all SQL to stdout
INFO  - Query language substitutions: {}
INFO  - cache provider: net.sf.hibernate.cache.HashtableCacheProvider
INFO  - instantiating and configuring caches
INFO  - building session factory
INFO  - no JNDI name configured
Hibernate: select host0_.HOST_ID as HOST_ID, host0_.AFFILIATE_ID as AFFILIAT2_, host0_.APP as APP, host0_.BG_COLOR as BG_COLOR, host0_.BG_IMAGE as BG_IMAGE, host0_.PRODUCT_DISCOUNT as PRODUCT_6_, host0_.SHIP_DISCOUNT_TYPE as SHIP_DIS7_, host0_.SHIP_DISCOUNT_AMT as SHIP_DIS8_, host0_.PAGE_HEADER as PAGE_HEA9_, host0_.PRIMARY_URL as PRIMARY10_, host0_.CART_LINK as CART_LINK, host0_.SHIP_TO_STORE as SHIP_TO12_, host0_.FONT_COLOR as FONT_COLOR, host0_.FONT_NAME as FONT_NAME, host0_.BORDER_COLOR as BORDER_15_, host0_.SHOW_UNAVAILABLE as SHOW_UN16_ from affiliate.HOST host0_
Hibernate: select affiliate0_.AFFILIATE_ID as AFFILIAT1_0_, affiliate0_.NAME as NAME0_, affiliate0_.ORDER_NOTIFICATION_EMAIL as ORDER_NO3_0_, affiliate0_.CUSTOMER_COMM_EMAIL as CUSTOMER4_0_, affiliate0_.VENDOR_CUST_ID as VENDOR_C5_0_, affiliate0_.FTP_ID as FTP_ID0_, affiliate0_.SHIP_METHOD as SHIP_MET7_0_, affiliate0_.GIFT_MSG as GIFT_MSG0_, affiliate0_.STATUS as STATUS0_ from affiliate.AFFILIATE affiliate0_ where affiliate0_.AFFILIATE_ID=?
net.sf.hibernate.UnresolvableObjectException: No row with the given identifier exists: 1, of class: com.muze.sphynx.affiliate.hibernate.Affiliate
   at net.sf.hibernate.UnresolvableObjectException.throwIfNull(UnresolvableObjectException.java:38)
   at net.sf.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:1918)
   at net.sf.hibernate.type.ManyToOneType.resolveIdentifier(ManyToOneType.java:68)
   at net.sf.hibernate.type.EntityType.resolveIdentifier(EntityType.java:215)
   at net.sf.hibernate.type.ComponentType.resolveIdentifier(ComponentType.java:389)
   at net.sf.hibernate.type.ComponentType.nullSafeGet(ComponentType.java:145)
   at net.sf.hibernate.type.ManyToOneType.hydrate(ManyToOneType.java:60)
   at net.sf.hibernate.type.ComponentType.hydrate(ComponentType.java:371)
   at net.sf.hibernate.type.ComponentType.nullSafeGet(ComponentType.java:145)
   at net.sf.hibernate.loader.Loader.getKeyFromResultSet(Loader.java:352)
   at net.sf.hibernate.loader.Loader.doQuery(Loader.java:203)
   at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
   at net.sf.hibernate.loader.Loader.doList(Loader.java:950)
   at net.sf.hibernate.loader.Loader.list(Loader.java:941)
   at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:834)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1512)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1491)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1483)
   at Tester.main(Tester.java:26)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:41)
   at java.lang.reflect.Method.invoke(Method.java:386)
   at com.intellij.rt.execution.application.AppMain.main(Unknown Source)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 19, 2004 7:09 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
What's the difference between Affiliate, AffiliateApp

It seems that Affiliate 1 -> n AffiliateApp
Host n-> AffiliateApp

But you don't show the whole mapping (BTW remove extra properties for the etst duration).

Are you sure you DB is consistent ? (the host instance you're loading seems to point to an AffiliateApp that points to a non existing Affiliate).

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 20, 2004 10:43 am 
Newbie

Joined: Thu Feb 19, 2004 5:12 pm
Posts: 6
Hey Emmanuel, thanks for the help.hrm, as far as i can tell the db is consistent. I'm going to look more. but in the meantime here are the additional mappings.

Affiliate
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>
<!--
    Created by the Middlegen Hibernate plugin

    http://boss.bekk.no/boss/middlegen/
    http://hibernate.sourceforge.net/
-->

<class
    name="com.muze.sphynx.affiliate.hibernate.Affiliate"
    table="AFFILIATE"
>
    <meta attribute="class-description" inherit="false">
       @hibernate.class
        table="AFFILIATE"
    </meta>

    <id
        name="affiliateId"
        type="java.lang.Integer"
        column="AFFILIATE_ID"
    >
        <meta attribute="field-description">
           @hibernate.id
            generator-class="assigned"
            type="java.lang.Integer"
            column="AFFILIATE_ID"

        </meta>
        <generator class="assigned" />
    </id>

    <property
        name="name"
        type="java.lang.String"
        column="NAME"
        length="100"
    >
        <meta attribute="field-description">
           @hibernate.property
            column="NAME"
            length="100"
        </meta>   
    </property>
    <property
        name="orderNotificationEmail"
        type="java.lang.String"
        column="ORDER_NOTIFICATION_EMAIL"
        length="50"
    >
        <meta attribute="field-description">
           @hibernate.property
            column="ORDER_NOTIFICATION_EMAIL"
            length="50"
        </meta>   
    </property>
    <property
        name="customerCommEmail"
        type="java.lang.String"
        column="CUSTOMER_COMM_EMAIL"
        length="50"
    >
        <meta attribute="field-description">
           @hibernate.property
            column="CUSTOMER_COMM_EMAIL"
            length="50"
        </meta>   
    </property>
    <property
        name="vendorCustId"
        type="java.lang.String"
        column="VENDOR_CUST_ID"
        length="20"
    >
        <meta attribute="field-description">
           @hibernate.property
            column="VENDOR_CUST_ID"
            length="20"
        </meta>   
    </property>
    <property
        name="ftpId"
        type="java.lang.String"
        column="FTP_ID"
        length="20"
    >
        <meta attribute="field-description">
           @hibernate.property
            column="FTP_ID"
            length="20"
        </meta>   
    </property>
    <property
        name="shipMethod"
        type="java.lang.String"
        column="SHIP_METHOD"
        length="10"
    >
        <meta attribute="field-description">
           @hibernate.property
            column="SHIP_METHOD"
            length="10"
        </meta>   
    </property>
    <property
        name="giftMsg"
        type="java.lang.String"
        column="GIFT_MSG"
        length="60"
    >
        <meta attribute="field-description">
           @hibernate.property
            column="GIFT_MSG"
            length="60"
        </meta>   
    </property>
    <property
        name="status"
        type="java.lang.Integer"
        column="STATUS"
        length="3"
    >
        <meta attribute="field-description">
           @hibernate.property
            column="STATUS"
            length="3"
        </meta>   
    </property>

    <!-- associations -->
    <!-- bi-directional one-to-many association to Contact -->
    <set
        name="contacts"
        lazy="true"
        inverse="true"
    >
        <meta attribute="field-description">
           @hibernate.set
            lazy="true"
            inverse="true"

          @hibernate.collection-key
           column="AFFILIATE_ID"

           @hibernate.collection-one-to-many
            class="com.muze.sphynx.affiliate.hibernate.Contact"
        </meta>
        <key>
            <column name="AFFILIATE_ID" />
        </key>
        <one-to-many
            class="com.muze.sphynx.affiliate.hibernate.Contact"
        />
    </set>
    <!-- bi-directional one-to-many association to Login -->
    <set
        name="logins"
        lazy="true"
        inverse="true"
    >
        <meta attribute="field-description">
           @hibernate.set
            lazy="true"
            inverse="true"

          @hibernate.collection-key
           column="AFFILIATE_ID"

           @hibernate.collection-one-to-many
            class="com.muze.sphynx.affiliate.hibernate.Login"
        </meta>
        <key>
            <column name="AFFILIATE_ID" />
        </key>
        <one-to-many
            class="com.muze.sphynx.affiliate.hibernate.Login"
        />
    </set>
    <!-- bi-directional one-to-many association to AffiliateApp -->
    <set
        name="affiliateApps"
        lazy="true"
        inverse="true"
    >
        <meta attribute="field-description">
           @hibernate.set
            lazy="true"
            inverse="true"

          @hibernate.collection-key
           column="AFFILIATE_ID"

           @hibernate.collection-one-to-many
            class="com.muze.sphynx.affiliate.hibernate.AffiliateApp"
        </meta>
        <key>
            <column name="AFFILIATE_ID" />
        </key>
        <one-to-many
            class="com.muze.sphynx.affiliate.hibernate.AffiliateApp"
        />
    </set>

</class>
</hibernate-mapping>


AffiliateApp
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>
<!--
    Created by the Middlegen Hibernate plugin

    http://boss.bekk.no/boss/middlegen/
    http://hibernate.sourceforge.net/
-->

<class
    name="com.muze.sphynx.affiliate.hibernate.AffiliateApp"
    table="AFFILIATE_APP"
>
    <meta attribute="class-description" inherit="false">
       @hibernate.class
        table="AFFILIATE_APP"
    </meta>

    <composite-id>
        <meta attribute="class-description" inherit="false">
           @hibernate.id
            generator-class="assigned"
        </meta>
        <key-property
            name="app"
            column="APP"
            type="java.lang.Integer"
            length="2"
        >
            <meta attribute="field-description">
               @hibernate.property
                column="APP"
                length="2"
            </meta>
        </key-property>
        <!-- bi-directional many-to-one association to Affiliate -->
        <key-many-to-one
           name="affiliate"
           class="com.muze.sphynx.affiliate.hibernate.Affiliate"
       >
            <meta attribute="field-description">
               @hibernate.many-to-one
                column="AFFILIATE_ID""
            </meta>
           <column name="AFFILIATE_ID" />
       </key-many-to-one>
    </composite-id>   


    <!-- associations -->
    <!-- bi-directional one-to-many association to Anno -->
    <set
        name="annos"
        lazy="true"
        inverse="true"
    >
        <meta attribute="field-description">
           @hibernate.set
            lazy="true"
            inverse="true"

          @hibernate.collection-key
           column="AFFILIATE_ID"
          @hibernate.collection-key
           column="APP"

           @hibernate.collection-one-to-many
            class="com.muze.sphynx.affiliate.hibernate.Anno"
        </meta>
        <key>
            <column name="AFFILIATE_ID" />
            <column name="APP" />
        </key>
        <one-to-many
            class="com.muze.sphynx.affiliate.hibernate.Anno"
        />
    </set>
    <!-- bi-directional one-to-many association to Category -->
    <set
        name="categories"
        lazy="true"
        inverse="true"
    >
        <meta attribute="field-description">
           @hibernate.set
            lazy="true"
            inverse="true"

          @hibernate.collection-key
           column="AFFILIATE_ID"
          @hibernate.collection-key
           column="APP"

           @hibernate.collection-one-to-many
            class="com.muze.sphynx.affiliate.hibernate.Category"
        </meta>
        <key>
            <column name="AFFILIATE_ID" />
            <column name="APP" />
        </key>
        <one-to-many
            class="com.muze.sphynx.affiliate.hibernate.Category"
        />
    </set>
    <!-- bi-directional one-to-many association to Selection -->
    <set
        name="selections"
        lazy="true"
        inverse="true"
    >
        <meta attribute="field-description">
           @hibernate.set
            lazy="true"
            inverse="true"

          @hibernate.collection-key
           column="AFFILIATE_ID"
          @hibernate.collection-key
           column="APP"

           @hibernate.collection-one-to-many
            class="com.muze.sphynx.affiliate.hibernate.Selection"
        </meta>
        <key>
            <column name="AFFILIATE_ID" />
            <column name="APP" />
        </key>
        <one-to-many
            class="com.muze.sphynx.affiliate.hibernate.Selection"
        />
    </set>
    <!-- bi-directional one-to-many association to Host -->
    <set
        name="hosts"
        lazy="true"
        inverse="true"
    >
        <meta attribute="field-description">
           @hibernate.set
            lazy="true"
            inverse="true"

          @hibernate.collection-key
           column="AFFILIATE_ID"
          @hibernate.collection-key
           column="APP"

           @hibernate.collection-one-to-many
            class="com.muze.sphynx.affiliate.hibernate.Host"
        </meta>
        <key>
            <column name="AFFILIATE_ID" />
            <column name="APP" />
        </key>
        <one-to-many
            class="com.muze.sphynx.affiliate.hibernate.Host"
        />
    </set>

</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 20, 2004 10:45 am 
Newbie

Joined: Thu Feb 19, 2004 5:12 pm
Posts: 6
emmanuel wrote:
What's the difference between Affiliate, AffiliateApp

It seems that Affiliate 1 -> n AffiliateApp
Host n-> AffiliateApp

But you don't show the whole mapping (BTW remove extra properties for the etst duration).

Are you sure you DB is consistent ? (the host instance you're loading seems to point to an AffiliateApp that points to a non existing Affiliate).


Oh the idea behind AffiliateApp is that each Affiliate can have any number of Applications.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 20, 2004 11:06 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Code:
<column name="AFFILIATE_ID" />
<column name="APP" />


Should be
Code:
<column name="APP" />
<column name="AFFILIATE_ID" />


The order of columns declaration must be the same as the composite-id declaration.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 20, 2004 11:51 am 
Newbie

Joined: Thu Feb 19, 2004 5:12 pm
Posts: 6
WOOH! Thanks! It must be a bug with middlegen's generation I guess, because I hand edited the hbm's as you said and reordered the columns and it works perfect now.

Thanks Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 20, 2004 11:57 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
David, do you confirm middlegen does not guarantee column order ?
Hibernate depends on that for many-to-one to composite-id

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 20, 2004 12:59 pm 
Newbie

Joined: Thu Feb 19, 2004 5:12 pm
Posts: 6
for what its worth I'm using Middlegen-Hibernate-r4


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 21, 2004 1:50 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Sorry but it is true that in certain situations it mucks up the column order. This is a known issue. The level of complexity composite keys adds is well....its a pain. Next release this is will be fixed (its not in CVS as yet as I am playing with another idea with dealing with composite keys - there are some other mapping combinations that it does not quite get right as well).


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 23, 2004 3:29 pm 
Newbie

Joined: Tue Dec 09, 2003 8:31 am
Posts: 17
I am having the same issue as the original poster. I was wondering if there is a temporary workaround I can make, other than hand editing the file.

Can I make a change to hibernate.vm file?

Thanks,

Craig


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