-->
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: Session Bean Hi/Lo Generator cannot configure TableHiLoGener
PostPosted: Fri Jul 23, 2004 1:52 pm 
Newbie

Joined: Thu Jul 22, 2004 4:32 pm
Posts: 6
Location: Sacramento, CA USA
I'm using Hibernate 2.1.1 with a J2EE application using a PointBase database.

Because the application work is done within a CMT, I'm trying to implement a Session Bean Hi/Lo Generator.

I have the EJB coded based on other posts I've seen in this forum, but am getting an exception when trying to configure the TableHiLoGenerator instance.

The code that is having the problem is here:

Code:
gen = new TableHiLoGenerator();
gen.configure(Hibernate.LONG, null, Dialect.getDialect());


When this runs, I get an error that the Dialect is not set. However,
the application includes, on its classpath, the hibernate.cfg.xml
file, which includes the following element in the <session-factory> element:

Code:
<property name="dialect">
  net.sf.hibernate.dialect.PointbaseDialect
</property>


I tried creating a Properties object with the following entry:

key: "hibernate.dialect"
value: "net.sf.hibernate.dialect.PointbaseDialect"

and passed it to getDialect(), but I then got a NullPointerExcception when the configure method tried to look up the table name in the properties.
I stopped at this point, as I think the dialect and table names, etc. should already be available to the application, so something must not be configured properly.

Here is the code used in my Session Bean Hi/Lo Generator. Can someone please tell me what I'm doing wrong? Note: I am not showing my IdentifierGenerator implementation class here. If you need to see that as well, I can post it.

Thanks,

Code:
public Long next (
   ) throws HibernateException
{
   if ( gen == null )
       {
       gen = new TableHiLoGenerator();
       // java.util.Properties props = new java.util.Properties();
       // props.put("hibernate.dialect", "net.sf.hibernate.dialect.PointbaseDialect");
       // gen.configure(Hibernate.LONG, null, Dialect.getDialect(props));

       gen.configure(Hibernate.LONG, null, Dialect.getDialect());
       }

        try
       {
       Session session = getSession();

       if (session instanceof SessionImplementor)
           {
      Long retval = (Long)gen.generate((SessionImplementor)session, null);

      return retval;
      }
       else
           {
      throw new HibernateException (
          "getSession() did not deliver a SessionImplementor"
          );
      }
       }
   catch ( SQLException sqlEx)
       {
       throw new HibernateException(sqlEx);
       }
} // next()

private SessionFactory getSessionFactory (
        ) throws HibernateException
{
        if (sessionFactory == null)
       {
       sessionFactory = new Configuration().configure().buildSessionFactory();
       }
        return sessionFactory;
} // getSessionFactory()

private Session getSession (
        ) throws HibernateException
{
        return getSessionFactory().openSession();
} // getSession()


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.