-->
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.  [ 5 posts ] 
Author Message
 Post subject: Cannot Instantiate Id Generator?
PostPosted: Mon Feb 07, 2005 1:25 pm 
Regular
Regular

Joined: Tue Jan 11, 2005 8:55 pm
Posts: 53
Hi -

I am using Hibernate 2.1.7 and Oracle 9 DB, and I have been stuck on this issue for a quite a while - *any* help would be appreciated! I've tried multiple ways to fix this problem, but so far no luck.

I am trying to use the sequence generator class, however, I continue to get the following error when I use the SchemaExport tool:


Code:
     [java] Feb 7, 2005 8:58:26 AM net.sf.hibernate.tool.hbm2ddl.SchemaExport main
     [java] SEVERE: Error creating schema
     [java] net.sf.hibernate.MappingException: could not instantiate id generator
     [java] at net.sf.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:82)
     [java] at net.sf.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:82)
     [java] at net.sf.hibernate.cfg.Configuration.iterateGenerators(Configuration.java:434)
     [java] at net.sf.hibernate.cfg.Configuration.generateDropSchemaScript(Configuration.java:493)
     [java] at net.sf.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:58)
     [java] at net.sf.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:48)
     [java] at net.sf.hibernate.tool.hbm2ddl.SchemaExport.main(SchemaExport.java:303)
     [java] Caused by: java.lang.ClassNotFoundException:
     [java] at java.lang.Class.forName0(Native Method)
     [java] at java.lang.Class.forName(Unknown Source)
     [java] at net.sf.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:102)
     [java] at net.sf.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:76)
     [java] ... 6 more


Here are my set of xDoclet tags for my java class:

Code:
   /**
    * @hibernate.id name="id" column="ADDRESS_ID"
    *                type="long"
    *                generator-class="native"
    * @hibernate.generator-param name="sequence" value="my_seq"
    * @return Returns the addressId.
    */
   public long getAddressId() {
      return addressId;
   }


And here is my Hibernate Properties file:

Code:
hibernate.dialect net.sf.hibernate.dialect.Oracle9Dialect
hibernate.connection.driver_class oracle.jdbc.driver.OracleDriver
hibernate.connection.username user
hibernate.connection.password pwd
hibernate.connection.url jdbc:oracle:thin:@xxxxx

Code:

It was working fine when I was using generator-class="uuid.string", and now when I switched to "sequence", I run into these errors... (I also get these errors when I use generator-class='native')

please help!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 07, 2005 1:35 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
check the generated hbm


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 07, 2005 1:44 pm 
Regular
Regular

Joined: Tue Jan 11, 2005 8:55 pm
Posts: 53
michael wrote:
check the generated hbm


I have checked the generated hbm and nothing odd stands out..?

Here it is:
Code:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping
>
    <class
        name="Address"
        table="ADDRESS"
        dynamic-update="false"
        dynamic-insert="false"
        select-before-update="false"
        optimistic-lock="version"
    >

        <id
            name="addressId"
            column="ADDRESS_ID"
            type="long"
        >
            <generator class="sequence">
                <param name="sequence">my_seq</param>
              <!-- 
                  To add non XDoclet generator parameters, create a file named
                  hibernate-generator-params-Address.xml
                  containing the additional parameters and place it in your merge dir.
              -->
            </generator>
        </id>

        <property
            name="streetAddressLine1"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="ADDRESS_LINE_1"
            length="500"
            not-null="true"
        />

        <property
            name="streetAddressLine2"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="ADDRESS_LINE_2"
            length="500"
        />

        <property
            name="city"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="CITY"
            length="250"
            not-null="true"
        />

        <property
            name="countryCode"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="COUNTRY"
            length="50"
            not-null="true"
        />

        <property
            name="stateCode"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="STATE"
            length="50"
            not-null="true"
        />

        <property
            name="status"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="STATUS"
            length="500"
            not-null="true"
        />

   
        <property
            name="postalCode"
            type="java.lang.String"
            update="true"
            insert="true"
            access="property"
            column="ZIP_CODE"
            length="50"
            not-null="true"
        />

        <!--
            To add non XDoclet property mappings, create a file named
                hibernate-properties-Address.xml
            containing the additional properties and place it in your merge dir.
        -->

    </class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 07, 2005 3:46 pm 
Regular
Regular

Joined: Tue Jan 11, 2005 8:55 pm
Posts: 53
To further add on, I get the error I mentioned above after the following statements "processing foreign key constraints" ( I forgot to paste that part too). See below:

Code:
     [java] 11:27:52,090  INFO Configuration: processing one-to-one association property references
     [java] 11:27:52,090  INFO Configuration: processing foreign key constraints
     [java] net.sf.hibernate.MappingException: could not instantiate id generator
     [java] at net.sf.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:82)
     [java] at net.sf.hibernate.mapping.SimpleValue.createIdentifierGenerator(SimpleValue.java:82)
     [java] at net.sf.hibernate.cfg.Configuration.iterateGenerators(Configuration.java:434)
     [java] at net.sf.hibernate.cfg.Configuration.generateDropSchemaScript(Configuration.java:493)
     [java] at net.sf.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:58)
     [java] at net.sf.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:48)
     [java] at net.sf.hibernate.tool.hbm2ddl.SchemaExport.main(SchemaExport.java:303)
     [java] Caused by: java.lang.ClassNotFoundException:
     [java] at java.lang.Class.forName0(Native Method)
     [java] at java.lang.Class.forName(Unknown Source)
     [java] at net.sf.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:102)
     [java] at net.sf.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:76)


Can anyone give more info so I can troubleshoot the problem?


Top
 Profile  
 
 Post subject: Re: Cannot Instantiate Id Generator?
PostPosted: Tue Feb 08, 2005 3:23 pm 
Regular
Regular

Joined: Tue Jan 11, 2005 8:55 pm
Posts: 53
FYI, I resolved this issue. I was using xDoclet tags for my java classes. Here were my original tags:

Code:
   /**
    * @hibernate.id name="id" column="ADDRESS_ID"
    *                type="long"
    *                generator-class="sequence"
    * @hibernate.generator-param name="sequence" value="my_seq"
    * @return Returns the addressId.
    */
   public long getAddressId() {
      return addressId;
   }


And when I removed the type='long' attribute and let SchemaExport specify the type, it worked perfectly fine:

Code:
   /**
    * @hibernate.id name="id" column="ADDRESS_ID"
    *                generator-class="sequence"
    * @hibernate.generator-param name="sequence" value="my_seq"
    * @return Returns the addressId.
    */
   public long getAddressId() {
      return addressId;
   }


I'm not sure why it won't work when I explicity state the type. At least it's resolved though! :)


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