This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]" Watch "Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]" New topic
Author

Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]

Rob Hope
Ranch Hand

Joined: Mar 31, 2012
Posts: 42
I am seeing this error shown when I start my project on Tomcat and then any classes relying on sessions fail
such as Session session = sessionFactory.openSession();

Any Ideas?

Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2840
    
  11

Usually that means there's no getter or setter in your POJO to match a property defined in your Hibernate mappings. Even a spelling error or an incorrect capitalization could cause this though, so look carefully.
Rob Hope
Ranch Hand

Joined: Mar 31, 2012
Posts: 42
I don't have any POJO in my mapping file

Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2840
    
  11

Please use code tags even for XML. They make it nicer to read and easier to refer to. I've added them for you here.

On line 5, Customer is a POJO, i.e., a plain old Java object ... so-called because it doesn't require to inherit from any Hibernate classes or paste in any Hibernate code to work. All it needs are getters and setters matching the definitions in this mapping file. It's very persnickety about the matching, and the error you're getting is saying something doesn't match. It could be a type, it could be a spelling error, it could even be the wrong casing. Some trial and error may be necessary. Remove the mappings one by one until you determine which one is causing the problem. If you still can't find it, post your Customer.java code here, and we'll look at it.
Rob Hope
Ranch Hand

Joined: Mar 31, 2012
Posts: 42
I thought I had the getters and setters in this class

Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2840
    
  11

setcreatedDate() should be setCreatedDate(), it should be implemented, and there should be an implemented getter.
Rob Hope
Ranch Hand

Joined: Mar 31, 2012
Posts: 42
I corrected this as below in my model but now my action class is showing

The method setcreatedDate(Date) is undefined for the type Customer



Rob Hope
Ranch Hand

Joined: Mar 31, 2012
Posts: 42
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2840
    
  11

Good, it looks like you figured out how to correct CustomerAction on your own. Is everything working now?
Rob Hope
Ranch Hand

Joined: Mar 31, 2012
Posts: 42
Yes - I no longer receive the tuplizer error, many thanks!

But I still receive a NPE from hibernate on attempting to submit to the database... does anyone have any ideas why?

org.hibernate.PropertyValueException: not-null property references a null or transient value: com.paul.customer.model.Customer.createdDate


Ive corrected my getter & setter for createdDate as below


Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2840
    
  11

It means your database CREATED_DATE field is defined with a NOT NULL constraint, and when you go to save your Customer, the createdDate field is null.
Rob Hope
Ranch Hand

Joined: Mar 31, 2012
Posts: 42
Okay.. thats the why but what I really meant was how to make sure the createdDate field is populated

I thought this method in the action.class was handling this?

customer.setCreatedDate(new Date());

Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3817

Rob Hope wrote:I thought this method in the action.class was handling this?

Does it set the date before it get persisted?


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Rob Hope
Ranch Hand

Joined: Mar 31, 2012
Posts: 42
in my model & action I employ the java date utility
import java.util.Date;

So i'm expecting it to populate with the method
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3817

...So i'm expecting it to populate with the method...

What method and how?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Unable to instantiate default tuplizer [org.hibernate.tuple.entity.PojoEntityTuplizer]
 
Similar Threads
How to do paging in struts
destroy sessionContext from EJB?
session in Strut2
SLSB as Session Fa├žade
Can one action be mapped to more than one ActionForm?