Hello,
i have a problem with the following simple data model:
- I create a data model with a schema
- The schema is transfered to java classes via jaxb/hyperjaxb3
- All jpa annotations are created sucessful also the dd scripts
The datamodel has two entities:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = “”, propOrder = {“job”})
@XmlRootElement(name = “project”)
@Entity(name = “Project”)
@Table(name = “PROJECT”)
@Inheritance(strategy = InheritanceType.JOINED)
public class Project implements Serializable
{
private final static long serialVersionUID = 1L;
@XmlElement(required = true)
protected List<Job> job;
@XmlAttribute(name = "customer", required = true)
protected String customer;
@XmlAttribute(name = "Hjid")
protected Long hjid;
@OneToMany(targetEntity = Job.class, cascade = { CascadeType.ALL})
@JoinColumn(name = "JOB_PROJECT_HJID")
public List<Job> getJob() {
if (job == null) {
job = new ArrayList<Job>();
}
return this.job;
}
and the job entity:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = “”, propOrder = {})
@XmlRootElement(name = “job”)
@Entity(name = “Job”)
@Table(name = “JOB”)
@Inheritance(strategy = InheritanceType.JOINED)
public class Job implements Serializable
{
private final static long serialVersionUID = 1L;
@XmlElement(required = true)
protected String name;
@XmlElement(required = true)
protected String id;
@XmlElement(required = true)
protected Files files;
@XmlAttribute(name = "Hjid")
protected Long hjid;
@Basic
@Column(name = "NAME_", length = 255)
public String getName() {
return name;
}
…
For the data access i create two JPAContainer:
JPAContainer<Project> projectContainer = JPAContainerFactory.make(Project.class, "persistenceUnit");
JPAContainer<Job> jobListContainer = JPAContainerFactory.make(Job.class, "persistenceUnit");
I add an filter:
jobListContainer.addContainerFilter(new Equal(“JOB_PROJECT_HJID”,localProjectFilter));
the locallocalProjectFilter is the selected entity from the table project with “projectContainer” as datasource.
The problem is that i wan’t to tables, one for all projects and if i select one project i wan’t to see the jobs in a second table. When a try to use a filter on the second table i got an error because the join column is not found in the job class. This is normaly ok, because the join column is created by the dd scripts and are avaible. Also when i save a new project entitiy with some jobs it works by using the JPAContainer.
I get the following message:
The attribute [JOB_PROJECT_HJID]
from the managed type [EntityTypeImpl@365390668:Job [ javaType: class de.domain.Job descriptor: RelationalDescriptor(de.domain.Job → [DatabaseTable(JOB)]
), mappings: 4]] is not present.
That means that the annotation @OneToMany(targetEntity = Job.class, cascade = { CascadeType.ALL}), @JoinColumn(name = “JOB_PROJECT_HJID”) is not found in the Job class.
How i can solve this problem?
Thanks for help.