Org.hibernate.InstantiationException: How to tell Hibernate which class to use for object instantiation?

The problem is occurring because a component is not a stand-alone entity, but a class whose instances are stored as an intrinsic part of an owning entity and share the identity of the entity In JPA terms it is considered an Embeddable class. These classes are usually used to create a class object out of a number of table columns that would normally have to be stored as individual attributes in an entity (you can almost look at it as grouping) While there are a number of benefits to this approach, there are some restrictions. One of these restrictions are that the component or embeddable cannot be an abstract class.

The reason being that there isn't any way for hibernate to associate a particular concrete subclass with the value you are trying to store or read. Think of it this way: would you be able to tell what instance to create by only looking at the column data? It's usually not that straight forward, especially for the persistence engine In order to get the functionality you desire, you will want to look into storing MailServer data as a separate entity with its own primary key field.

Doing so allows you to manage the data with subclasses using various inheritance methods such as including a DiscriminatorColumn or separate tables (depending on your configuration) Here are some links that should help you with setting up these mappings and using entity inheritance: One-to-One mapping example (useful if not reusing MailServer data Inheritance overview Useful bernate examples (not latest spec, but gives you good overview) Hope this helps http://www.vaannila.com/hibernate/hibernate-example/hibernate-example.html If you were to use this approach using bernate (I personally prefer JPA-based Annotation configurations), you could configure MailServer as an abstract entity that would define the common column mappings between the classes and a DiscriminatorColumn (if using same table inheritance). The subclasses would be built off of this definition, adding custom attributes as needed.

The problem is occurring because a component is not a stand-alone entity, but "a class whose instances are stored as an intrinsic part of an owning entity and share the identity of the entity". In JPA terms it is considered an Embeddable class. These classes are usually used to create a class object out of a number of table columns that would normally have to be stored as individual attributes in an entity (you can almost look at it as grouping).

While there are a number of benefits to this approach, there are some restrictions. One of these restrictions are that the component or embeddable cannot be an abstract class. The reason being that there isn't any way for hibernate to associate a particular concrete subclass with the value you are trying to store or read.

Think of it this way: would you be able to tell what instance to create by only looking at the column data? It's usually not that straight forward, especially for the persistence engine. In order to get the functionality you desire, you will want to look into storing MailServer data as a separate entity with its own primary key field.

Doing so allows you to manage the data with subclasses using various inheritance methods such as including a DiscriminatorColumn or separate tables (depending on your configuration). Here are some links that should help you with setting up these mappings and using entity inheritance: One-to-One mapping example (useful if not reusing MailServer data. Inheritance overview Useful bernate examples (not latest spec, but gives you good overview) Hope this helps.

http://www.vaannila.com/hibernate/hibernate-example/hibernate-example.html If you were to use this approach using bernate (I personally prefer JPA-based Annotation configurations), you could configure MailServer as an abstract entity that would define the common column mappings between the classes and a DiscriminatorColumn (if using same table inheritance). The subclasses would be built off of this definition, adding custom attributes as needed.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions