-->
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.  [ 2 posts ] 
Author Message
 Post subject: Problems mapping with a java.lang.Object
PostPosted: Mon Jan 02, 2006 9:38 am 
Beginner
Beginner

Joined: Wed Apr 20, 2005 9:30 am
Posts: 39
I've solved my problem temporarily by making a simple object wrapper class, but I've come across this problem that seems a little odd:

I have a class with a property of type java.lang.Object, I get the following exception:
org.hibernate.MappingException: property mapping has wrong number of columns: com.declivis.asc.dao.GenericStatus.objectWrapper type: object

Has anyone encountered this? I realize my workaround isn't really that painful, but I'm curious as to what the root of this problem is. Hibernate doesn't leave many clues in the log... it just throws this exception and shuts down.

More interesting to this point, is that I'm using the SchemaUpdate/Export mechanism(s) to build my tables in HSQLDB and it doesn't complain at all and builds the tables correctly. The failure comes once the attempt to build the session factory happens.

In case your curious - I'm using the subclasses to do the cast on this object to a type correct for the subclass.

Any thoughts or clues would be most appreciated.

Hibernate version: 3.0.5

Mapping documents:
<class name="com.declivis.asc.dao.GenericStatus" table="status">
<id name="id" type="int">
<column name="id" />
<generator class="identity" />
</id>
<discriminator column="type" type="string" length="3" />
<property name="key" type="string" >
<column name="key" length="64" index="IDX_GS_KEY"/>
</property>
<property name="state" type="int" >
<column name="state" length="3" />
</property>
<property name="objectWrapper" type="object" >
<column name="obj" sql-type="other" not-null="false" />
</property>
<subclass name="com.declivis.asc.dao.ProductStatus" discriminator-value="PFS" />
<subclass name="com.declivis.asc.dao.OrderStatus" discriminator-value="OFS" />
</class>

Code between sessionFactory.openSession() and session.close():
Session factory never gets running.

Full stack trace of any exception that occurs:
org.hibernate.MappingException: property mapping has wrong number of columns: com.declivis.asc.dao.GenericStatus.objectWrapper type: object

Name and version of the database you are using: HSQLDB 1.7.3

Debug level Hibernate log excerpt:
Jan 02 08:27:02 org.hibernate.tool.hbm2ddl.SchemaUpdate[INFO]: schema update complete
Jan 02 08:27:02 org.hibernate.cfg.Configuration[DEBUG]: Preparing to build session factory with filters : {}
Jan 02 08:27:02 org.hibernate.cfg.Configuration[INFO]: processing extends queue
Jan 02 08:27:02 org.hibernate.cfg.Configuration[INFO]: processing collection mappings
Jan 02 08:27:02 org.hibernate.cfg.Configuration[INFO]: processing association property references
Jan 02 08:27:02 org.hibernate.cfg.Configuration[INFO]: processing foreign key constraints
Jan 02 08:27:02 org.hibernate.cfg.Configuration[DEBUG]: resolving reference to class: com.declivis.asc.dao.InterimOrder
Jan 02 08:27:02 org.hibernate.cfg.Configuration[DEBUG]: resolving reference to class: com.declivis.asc.dao.Order
Jan 02 08:27:02 org.hibernate.impl.SessionFactoryImpl[INFO]: closing


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 03, 2006 5:13 am 
Newbie

Joined: Tue Jan 18, 2005 7:08 am
Posts: 10
I had this error, too.
However in my opinion it's never a good idea to map a property as "object".

Every data you save in the DB is either a String, a number, a date, some binary data etc. Why can't you map it as such?

If the predefined Hibernate-types don't meet your requisits, you can always write a user-type.


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