[jboss-user] [EJB 3.0] - @manytoone left join problem
enesterov
do-not-reply at jboss.com
Mon Dec 18 14:39:06 EST 2006
Hi everyone,
I have many-to-one unidirectional relationship between two objects as follows:
| @Entity
| @Table(name = "A")
| public class A implements Serializable {
|
| private Long id;
|
| private B bObject;
|
| @Id
| public Long getId() {
| return id;
| }
|
| public void setId(Long _id) {
| id = _id;
| }
|
| @ManyToOne
| @JoinColumn(name = "a_id", insertable = false, updatable = false, nullable = true)
| public B getBObject() {
| return bObject;
| }
|
| public void setBObject(B _bObject) {
| bObject = _bObject;
| }
| }
|
| @Entity
| @Table(name = "B")
| public class B implements Serializable {
|
| private Long id;
|
| private Long aId;
|
| @Id
| public Long getId() {
| return id;
| }
|
| public void setId(Long _id) {
| id = _id;
| }
|
| @Column(name="a_id")
| public Long getAId() {
| return id;
| }
|
| public void setAId(Long _aId) {
| aId = _aId;
| }
| }
|
in the session bean I am getting List as follows:
| ...
| Query query = em.createQuery("select a from A a left outer join a.bObject as b ");
| query.setFirstResult(start);
| query.setMaxResults(MSG_PER_PAGE);
| List<A> result =query.getResultList();
| ...
|
The problem is that every time there is no record in table B that corresponds to record in table A I am getting the javax.persistence.EntityNotFoundException: Unable to find B with id 123
I am running Jboss 4.0.4.
Any help is appreciated.
Ed
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3994778#3994778
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3994778
More information about the jboss-user
mailing list