I'm using open-jpa and as we know it's shipped with enhancer which could create non private no-arg constructor during enhancement. It works, however eclipse have problem with it. It's quite rational that it doesn't know anything what would happen during ant build, so is there any possibility to turn off this particular error The Java class for mapped type ... must define a non-private zero-argument constructor
bounded to @Entity annotation?
You don't have to provide any constructors for your class, but you must be careful when doing this. The compiler automatically provides a no-argument, default constructor for any class without constructors. This default constructor will call the no-argument constructor of the superclass.
No-Arg Constructor - a constructor that does not accept any arguments. Parameterized constructor - a constructor that accepts arguments. Default Constructor - a constructor that is automatically created by the Java compiler if it is not explicitly defined.
So if you won't have no-args constructor in entity beans, hibernate will fail to instantiate it and you will get `HibernateException`.
The JPA specification requires that all persistent classes have a no-arg constructor. This constructor may be public or protected. Because the compiler automatically creates a default no-arg constructor when no other constructor is defined, only classes that define constructors must also include a no-arg constructor.
This works for me (Eclipse Mars.1 Release 4.5.1)
Project / Properties / JPA / Errors/Warnings
Enable Project Specific Settings
Type
ID class must have a public no-arg constructor (change from Error to something else)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With