Hibernate unable to instantiate default tuplizer - cannot find getter

后端 未结 7 594
醉梦人生
醉梦人生 2021-01-01 17:41

I\'m trying to use Hibernate to persist a class that looks like this:

public class Item implements Serializable, Comparable {

// Item id
private         


        
相关标签:
7条回答
  • 2021-01-01 18:15

    Further on down the stack trace, it says this:

    missing a getter for puchaseDate
    

    You might want to check for typos ;) You're missing an R and setPurchasedate should be setPurchaseDate

    0 讨论(0)
  • 2021-01-01 18:16

    Pay attention to method name,It is case sensitive!

    In my case,it could not recognize getter very well; my property name was uId and I used getUId name for getter name and when I changed it to getuId problem solved!

    0 讨论(0)
  • 2021-01-01 18:18

    I experienced the

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

    because I had a momentary lapse of donkeyness when renaming a field on a POJO that I had previously mapped.

    I changed the Java attribute name with my trusty IDE refactor hotkey, which does not also change the getter & setter method names. I changed the getter (because it caught my attention with its @Column annotation that I also needed to address because the table column name was changing).

    I neglected, however, to change the setter, and that was the cause of the error.

    0 讨论(0)
  • 2021-01-01 18:27

    If it can help someone:

    In my case there were errors in my mapping files. Classes were not referenced by their full package names. I did this mistake because I generated the mappings when my bean classes belonged to the default package (hence no package name; e.g.: Order instead of com.mypackage.Order) and then I moved my bean classes to package (in the example com.mypackage). Unfortunately mapping files did not changed accordingly with the new package definition.

    My hint is redo Hibernate reverse engineering and see what it produces, comparing it with your current mapping files.

    0 讨论(0)
  • 2021-01-01 18:29

    It looks like the problem is probably in the capitalization: setPurchasedate() should be setPurchaseDate() (with a capital "D").

    0 讨论(0)
  • 2021-01-01 18:31

    I included java assit.jar and it worked

    <dependency>
        <groupId>javassist</groupId>
        <artifactId>javassist</artifactId>
        <version>3.12.1.GA</version>
    </dependency>
    
    0 讨论(0)
提交回复
热议问题