-->
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.  [ 6 posts ] 
Author Message
 Post subject: increment id generator not found
PostPosted: Mon Dec 15, 2003 9:36 pm 
Newbie

Joined: Mon Dec 15, 2003 7:03 pm
Posts: 12
Code snip here:


Code:
<hibernate-mapping>
    <class
        name="inventory.InventoryItem"
        table="inventory_item">

        <id name="ID"
            column="inventory_item_id"
            type="long"
            unsaved-value="-1">
            <generator class="increment"/>
        </id>



Error msg here:


2003-12-15 17:29:46,785 ERROR main test.inventory.InventoryItemTest - could not instantiate id generator: increment
java.lang.ClassNotFoundException: increment
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at net.sf.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:255)
at net.sf.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:64)
at net.sf.hibernate.mapping.Value.createIdentifierGenerator(Value.java:78)
at net.sf.hibernate.persister.AbstractEntityPersister.<init>(AbstractEntityPersister.java:489)
at net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:623)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:203)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:594)
at database.HibernateSesssionFactoryManager.getFactory(HibernateSesssionFactoryManager.java:40)
at test.inventory.InventoryItemTest.setUp(InventoryItemTest.java:35)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.textui.TestRunner.doRun(TestRunner.java:116)
at junit.textui.TestRunner.start(TestRunner.java:172)
at com.intellij.rt.execution.junit.TextTestRunner.main(TextTestRunner.java:12)
rethrown as
net.sf.hibernate.MappingException: could not instantiate id generator: increment
at net.sf.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:70)
at net.sf.hibernate.mapping.Value.createIdentifierGenerator(Value.java:78)
at net.sf.hibernate.persister.AbstractEntityPersister.<init>(AbstractEntityPersister.java:489)
at net.sf.hibernate.persister.EntityPersister.<init>(EntityPersister.java:623)
at net.sf.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:203)
at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:594)
at database.HibernateSesssionFactoryManager.getFactory(HibernateSesssionFactoryManager.java:40)
at test.inventory.InventoryItemTest.setUp(InventoryItemTest.java:35)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at junit.textui.TestRunner.doRun(TestRunner.java:116)
at junit.textui.TestRunner.start(TestRunner.java:172)
at com.intellij.rt.execution.junit.TextTestRunner.main(TextTestRunner.java:12)
Caused by: java.lang.ClassNotFoundException: increment
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at net.sf.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:255)
at net.sf.hibernate.id.IdentifierGeneratorFactory.create(IdentifierGeneratorFactory.java:64)
... 17 more


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 15, 2003 11:31 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
eh?? What version of Hibernate is this?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 16, 2003 2:37 pm 
Newbie

Joined: Mon Dec 15, 2003 7:03 pm
Posts: 12
I am using 2.0. This is not much of an issue for me because I will not be using increment. But somebody else might.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 16, 2003 9:16 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
increment was introduced in 2.0.1

why are you using an obsolete version of Hibernate? You should be using 2.0.3 at least.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 17, 2003 4:03 pm 
Newbie

Joined: Mon Dec 15, 2003 7:03 pm
Posts: 12
I am sorry Gavin, 2.0.3 is what I have. I didn't thik the minor version number was that important.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 17, 2003 5:24 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I have no idea what you are doing wrong. This is what the code looks like:
Code:

   static {
      GENERATORS.put("uuid.hex", UUIDHexGenerator.class);
      GENERATORS.put("uuid.string", UUIDStringGenerator.class);
      GENERATORS.put("hilo", TableHiLoGenerator.class);
      GENERATORS.put("assigned", Assigned.class);
      GENERATORS.put("identity", IdentityGenerator.class);
      GENERATORS.put("sequence", SequenceGenerator.class);
      GENERATORS.put("seqhilo", SequenceHiLoGenerator.class);
      GENERATORS.put("vm", IncrementGenerator.class); //vm is deprecated
      GENERATORS.put("increment", IncrementGenerator.class);
      GENERATORS.put("foreign", ForeignGenerator.class);
   }
   
   public static IdentifierGenerator create(String strategy, Type type, Properties params, Dialect dialect) throws MappingException {
      try {
         //if ( "vm".equals(strategy) ) log.info("'vm' strategy is deprecated; use 'increment'");
         
         Class clazz = (Class) GENERATORS.get(strategy);
         if ( "native".equals(strategy) ) {
            if ( dialect.supportsIdentityColumns() ) {
               clazz = IdentityGenerator.class;
            }
            else if ( dialect.supportsSequences() ) {
               clazz = SequenceGenerator.class;
            }
            else {
               clazz = TableHiLoGenerator.class;
            }
         }
         if (clazz==null) clazz = ReflectHelper.classForName(strategy);
         IdentifierGenerator idgen = (IdentifierGenerator) clazz.newInstance();
         if (idgen instanceof Configurable) ( (Configurable) idgen).configure(type, params, dialect);
         return idgen;
      }
      catch (Exception e) {
         throw new MappingException("could not instantiate id generator", e);
      }
   }


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