Java Mailing List Archive

http://www.gg3721.com/

Home » users.openjpa »

Need OUTER JOIN to SecondaryTable

gretchch

2008-06-13

Replies: Find Java Web Hosting

Author LoginPost Reply


It seems to me that I can't be the only person that ever wanted an outer
join to a secondary table, but I have spent a whole day searching the
internet for a solution, and haven't seen one (except for a
Hibernate-specific one). I have a main employee table that may or may not
have some extra data populated in a related secondary table. If there is
data in the secondary table, then I would like my Employee entity to have
those fields filled in. If there isn't data for a given employee in the
secondary table, then I would like my Employee entity to have nulls in
those fields. Right now, if there's no row in the secondary table for a
given employee, I get nothing. Is there any way to force openjpa to do an
OUTER JOIN to the secondary table? I am using the version of openjpa that
comes in the WebSphere 6.1 feature pack, so I believe I am constrained to
use openjpa 1.0.1, unless someone can give me a method to replace the IBM
supplied jars.

Here's example code:

@Entity
@Table("EMPLOYEE")
@SecondaryTable("EMPLOYEE_EXTRA",
       pkJoinColumns=@(protected)"))

public class Employee implements java.io.Serializable {

   private static final long serialVersionUID = -3789770304634576481L;

   @Column(table="EMPLOYEE_EXTRA",
       name="EMPLOYEE_EXTRA_DATA",nullable=true)
   private String employeeExtraData;

   @Id
   @GeneratedValue(strategy=GenerationType.IDENTITY)
   @Column(name="EMPLOYEE_KEY")
   private Long employeeKey;

...etc

}

Gretchen Chiaramonte

Sun Certified Java Programmer
IBM Certified MQSeries Engineer
IBM Systems & Technology Group, Development

Tel: 1-919-517-1750
Tie: 255-1750
email: chiaramg@(protected)
©2008 gg3721.com - Jax Systems, LLC, U.S.A.