-->
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.  [ 7 posts ] 
Author Message
 Post subject: MappingException when starting HibernateService
PostPosted: Fri Dec 16, 2005 4:53 pm 
Beginner
Beginner

Joined: Tue Nov 15, 2005 6:56 pm
Posts: 39
Hi everybody,

Using Hibernate 3.1 with POJOS generated by Hibernate-tools3.1-beta2


I'm in the process of upgrading some code that uses Hibernate 3.0ish code to the 3.1 version. I've updated the code to generate the POJOS correctly and compile correctly. However, when I start my JBoss Server, I'm getting an exception when a HibernateService derived service class is trying to start. So, we have a custom class that derives from HibernateService and it throws an exception.

Code:
Problem starting service mycompany.com:service=LogHibernate
org.hibernate.HibernateException: org.hibernate.MappingException: Could not determine type for: Boolean, for columns: [org.hibernate.mapping.Column(active_flg)
...
Caused by: org.hibernate.MappingException: Could not determine type for: Boolean, for columns: [org.hibernate.mapping.Column(active_flg)]
]


Now, I know to upgrade to the newest Hibernate-tools3.1beta2 I had to change my mapping files to explicity say "Boolean" vs "boolean". It seems like it may be related to that but I'm not sure how to fix it.

The place in the custom service class that the exception is thrown at is the second line of the code snippet below....when setSessionFactoryJNDIName is called.

Code:
MyCompanyStatisticsService stats = new MyCompanyStatisticsService();
            stats.setStatisticsEnabled(true);
            stats.setSessionFactoryJNDIName(this.getJndiName());



The MyCompanyStatisticsService class derives from org.hibernate.jmx.StatisticsService. The class that this code appears in is derived from is org.hibernate.jmx.HibernateService.

This code used to work before Hibernate 3.1. Anybody have any idea what's going on here?

Thank You.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 18, 2005 11:33 am 
Beginner
Beginner

Joined: Thu Dec 01, 2005 7:07 pm
Posts: 21
db server and correspnding col type pls


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 19, 2005 4:35 pm 
Beginner
Beginner

Joined: Tue Nov 15, 2005 6:56 pm
Posts: 39
We're using Oracle 10g and the database column is of type Number(1) in the database.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 19, 2005 4:51 pm 
Beginner
Beginner

Joined: Tue Nov 15, 2005 6:56 pm
Posts: 39
If it helps any, I traced the problem further in the hibernate code to the vlaidate() function in org.hibernate.cfg.Configuration class.

Code:
   private void validate() throws MappingException {
      Iterator iter = classes.values().iterator();
      while ( iter.hasNext() ) {
         ( (PersistentClass) iter.next() ).validate( mapping );
      }
      iter = collections.values().iterator();
      while ( iter.hasNext() ) {
         ( (Collection) iter.next() ).validate( mapping );
      }
   }


Since I was able to generate my POJOs during the build process using the new version of Hibernate3.1 and HibernateTools-3.1beta2, could it be that somehow JBOSS internally is using a different version of Hibernate somehow? I'm saying this, since it's complaining about the higher level type Boolean vs boolean. Using the higher level type Boolean is a new thing in hibernate.

The error is caused by this mapping:

Code:
        <property name="activeFlg" type="Boolean"/>


I don't think it's specific to type Boolean. I think it applies to all higher level types specified in the mapping files. Unfortunately, I have to specify the higher level types for the new version of Hibernate3.1 and it's toolset3.1beta2.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 19, 2005 5:58 pm 
Beginner
Beginner

Joined: Tue Nov 15, 2005 6:56 pm
Posts: 39
Some more debugging and I've narrowed it down to this line in SimpleValue class in method getType(...)

Code:
   public Type getType() throws MappingException {
      if (typeName==null) {
         throw new MappingException("No type name");
      }
      Type result = TypeFactory.heuristicType(typeName, typeParameters);
      if (result==null) {
         String msg = "Could not determine type for: " + typeName;
         if(columns!=null && columns.size()>0) {
            msg += ", for columns: " + columns;
         }
         throw new MappingException(msg);
      }
      return result;
   }


The line:

Code:
Type result = TypeFactory.heuristicType(typeName, typeParameters);


in the above code get a null for 'result' variable when 'typeName' is "Boolean" and typeParameters is null.

Anybody have ideas here?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 19, 2005 6:23 pm 
Beginner
Beginner

Joined: Tue Nov 15, 2005 6:56 pm
Posts: 39
Ok, I'm not sure if this is the right solution, but I got further in the start process of the service by specifying the full path of the higher level Java types in the mapping files. For example I did this:

Code:
        <property name="activeFlg" type="java.lang.Boolean"/>


However, I then get some new error like this:

Code:
Problem starting service mycompany.com:service=LogHibernate
org.hibernate.HibernateException: org.hibernate.MappingException: No Dialect mapping for JDBC type: -2
   at mycompany.common.jmx.MyHibernateService.start(MyHibernateService.java:135)


Any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 19, 2005 9:45 pm 
Beginner
Beginner

Joined: Tue Nov 15, 2005 6:56 pm
Posts: 39
I'm not sure if I'm making any progress here. I've narrowed down the error with the JDBC type: 02 problem to be related to a custom identifier mapping:

Code:
       <id name="evtLogId" type="mycompany.type.GuidType">
         <generator class="mycompanyt.common.id.GuidIdentifierGenerator"/>
      </id>


If I change this identifier to be just a simple identifier such as:
Code:
<id name="evtLogId" type="java.lang.Long"/>


it gets further in the build process but then gets other errors. I'm just wondering if I'm solving all these problems the wrong way.

I did notice in my build process early on that it had this INFO message:

Code:
Could not build SessionFactory using the MBean classpath - will try again using client classpath: No Dialect mapping for JDBC type: -2


Could that be related to all these issues? Is there somewhere where you specify classpath for mbeans?


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