-
1. Re: Stop automatic persist of parents children?
pieterjan Dec 27, 2005 3:46 AM (in response to pieterjan)
Interesting.
I found the following link http://e-docs.bea.com/workshop/docs81/doc/en/core/index.html at the bea website.
Where in the section 'Developing Enterprise JavaBean' > 'Developing Entity Beans' > 'Accelerating Entity Bean Data Access' they give a few pointers on how to make entity beans that are read only.
I wonder if I could do the same in JBoss and if this would prevent the server from trying to update each entity bean? -
2. Re: Stop automatic persist of parents children?
pieterjan Dec 28, 2005 4:25 AM (in response to pieterjan)I found out that the simple parent-child example I gave, does not produce the selection statements I was talking about. Instead a parent-child-grandchild relation does produce the problem.
I used the following classes to test (the getters and setters are removed here) :// Parent @Entity(access = AccessType.FIELD) @Table(name="t_tests", schema="grid") @SequenceGenerator(name="TestBeanSequence", sequenceName="grid.s_tests") public class TestBean implements Serializable { @Id(generate=GeneratorType.SEQUENCE, generator="TestBeanSequence") private Integer id; @Column(length=255) private String someText; @Basic(temporalType = TemporalType.TIMESTAMP) private Date someDate; private Boolean someBoolean; @OneToMany(targetEntity=TestChildBean.class, mappedBy="test", cascade=CascadeType.ALL, fetch=FetchType.LAZY) private List<TestChildBean> testChildren; } // Child @Entity(access = AccessType.FIELD) @Table(name="t_testchilds", schema="grid") @SequenceGenerator(name="TestChildBeanSequence", sequenceName="grid.s_testchilds") public class TestChildBean { @Id(generate=GeneratorType.SEQUENCE, generator="TestChildBeanSequence") private Integer id; @Column(length=20, nullable=false) private String name; @ManyToOne(targetEntity=TestBean.class, fetch=FetchType.LAZY) @JoinColumn(name="test_id", nullable = false) private TestBean test; @OneToMany(targetEntity=TestGrandChildBean.class, mappedBy="testChild", cascade=CascadeType.ALL, fetch=FetchType.LAZY) private List<TestGrandChildBean> testGrandChildren; } // Grandchild @Entity(access = AccessType.FIELD) @Table(name="t_testgrandchilds", schema="grid") @SequenceGenerator(name="TestGrandChildBeanSequence", sequenceName="grid.s_testgrandchilds") public class TestGrandChildBean { @Id(generate=GeneratorType.SEQUENCE, generator="TestGrandChildBeanSequence") private Integer id; @Column(length=20, nullable=false) private String name; @ManyToOne(targetEntity=TestChildBean.class, fetch=FetchType.LAZY) @JoinColumn(name="testchild_id", nullable = false) private TestChildBean testChild; }
-
3. Re: Stop automatic persist of parents children?
pieterjan Jan 6, 2006 5:12 AM (in response to pieterjan)Solved it!
Apparently it had nothing to do with read-only beans but with the way JBoss 4.0.2 checks for dirty entity beans.
Upgrading to 4.0.3SP1 solved the problem.
BTW, the performance increase is HUGE.