Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Rob Hope
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2987
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't have any POJO in my mapping file

 
Greg Charles
Sheriff
Posts: 2987
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought I had the getters and setters in this class

 
Greg Charles
Sheriff
Posts: 2987
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
setcreatedDate() should be setCreatedDate(), it should be implemented, and there should be an implemented getter.
 
Rob Hope
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Greg Charles
Sheriff
Posts: 2987
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good, it looks like you figured out how to correct CustomerAction on your own. Is everything working now?
 
Rob Hope
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2987
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Hope wrote:I thought this method in the action.class was handling this?

Does it set the date before it get persisted?
 
Rob Hope
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3913
9
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...So i'm expecting it to populate with the method...

What method and how?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic