users@glassfish.java.net

Why is it selecting from other entities?

From: <glassfish_at_javadesktop.org>
Date: Mon, 20 Aug 2007 11:39:30 PDT

Hi,

I have created three sample tables, EMPLOYEE, PHOTO and MANAGER. One manager can have many employees and each employee must have only one photo. I am using Toplink Essentials. I generated entities.

Here are my field defined annotations:

in Employee.java
    @ManyToOne
    @JoinColumn(name = "MANAGERNO", referencedColumnName = "MANAGERNO")
    private Manager manager;
    @OneToOne(mappedBy = "employee")
    protected Photo photo;

in Manager.java

    @OneToMany(mappedBy = "manager")
    private List<Employee> employeeList;

and in Photo.java

    @Lob
    @Basic
    private byte[] photo;
    @OneToOne
    @JoinColumn(name = "EMPNO", referencedColumnName = "EMPNO")
    private Employee employee;



I have a Java client as follows

<code>
...
            Long employeeNo = new Long(38);
            Employee employee = sessionEJB.getEmployee(employeeNo);
            System.out.println(employee.toString());
            Photo photo = employee.getPhoto();
...
</code>

I debug the code and stop right at the System.out.println line. When I look at the application server log, I am seeing that it is performing SELECT on three tables. Is this a normal behaviour?

Thanks in advance,

Mustafa
[Message sent by forum member 'mcayci' (mcayci)]

http://forums.java.net/jive/thread.jspa?messageID=231670