openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marco Schwarz <marco.schw...@cioppino.net>
Subject Question about @OneToMany
Date Tue, 22 Apr 2008 18:43:50 GMT
Hi,

I have a ModelObject, simple example

@MappedSuperclass
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
class ModelObject {

	@Id
	private int id

	@Transient
	ModelObject parent;

	@OneToMany(cascade={CascadeType.ALL}, fetch=FetchType.EAGER)
	List<ModelObject> children;

	public void addChild(ModelObject child) {
		if (children == null) {
			children = new ArrayList<ModelObject>();
		}
		children.add(child);
		child.setParent(this);
	}

	....

	public void setParent(ModelObject parent) {
		this.parent = parent;
	}

	.....

}

@Entity
class Company extends ModelObject {

}

@Entity
class Employer extends ModelObject {

}

...

public static void main(String[] args) {

	...

	Company company = new Company();

	Employer e;

	e = new Employer()
	e.setId("Person0");
	company.addChild(e);

	e = new Employer()
	e.setId("Person1");
	company.addChild(e);

	...

}

When I start my app the openjpa create 4 tables (Company, 
Company_children, Emplpyer and Employer_children).

How can I make only 2 tables?

thanks
Marco



	


Mime
View raw message