I'm trying to use a construction which appears not possible. My creation looks like this (well its a bit simplified):
myProcess.java
Code:
@Entity
@Table(name = "myprocess")
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorFormula("CONCAT(type, '-',action)")
public class myProcess {
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
@Column(name = "id", nullable = false)
private Integer id;
@Enumerated(EnumType.STRING)
@Column(name = "type", nullable = false)
private ProcessTypeEnum type;
@Column(name = "action", nullable = false)
private String action;
@Column(name = "status", nullable = false)
private String status;
.... <even more stuff and getter/setter> ....
}
contactProcess.java (Extends from myProcess)
Code:
@Entity
@Table(name = "process_contact")
public abstract class ContactProcess extends myProcess {
@Column(name = "name")
private String name;
@Column(name = "city")
private String city;
.... <even more stuff and getter/setter> ....
}
createContactProcess.java(Extends from ContactProcess)
Code:
public class CreateContactProcess extends ContactProcess {
...Business code...
public void SaveMe()
{
getEntityManager().persist(this);
}
}
The error i'm getting is:
Quote:
javax.ejb.EJBException: java.lang.IllegalArgumentException: Unknown entity: CreateContactProcess
The createcontactprocess only contains the business logic voor the create. There will also be a delete and update etc. I'm using the extends to prevent having to create the same entities over and over again. And I want to seperate the businesslogic code for a create and delete because its a lot of code.
Side note: In this example i'm not trying to persist the contact itself (like the name suggest) but the data in the createcontactprocess. Because the process can run for a long time and i want to save the data in case something happens with the application server.Putting the persist function in myprocess doenst change a thing because its being extended down to createContactProcess.
The error doesn't surprise me, but how can I avoid/fix it ?
Update:When I add @Entity to createContactProcess.java the code works as expected... The Process table and ContactProcess table are filled with the right data. But hibernate generates the table CreateContactProcess with only an Id column. This id column is linked to the Id columns of the other tables. This CreateContactProcess table is useless and shouldn't be created.
So another solution for me would be to prevent hibernate to create the CreateContractProcess table and prevent hibernate to set the Id column of the CreateContactProcess. Is this possible? Does hibernate contains an option to fully auto generate tables from the enities except for one entity (CreateContactProcess)?