| Summary: |
@JoinColumn(name="FK_DEPT",insertable = false, updatable = true) causes INSERT statement to include this data value that it is associated with |
| Product: |
z_Archived
|
Reporter: |
Stephen DiMilla <stephen.dimilla> |
| Component: |
Eclipselink | Assignee: |
Nobody - feel free to take it <nobody> |
| Status: |
RESOLVED
FIXED
|
QA Contact: |
|
| Severity: |
blocker
|
|
|
| Priority: |
P3
|
CC: |
eclipselink.orm-inbox, guy.pelletier, lance.andersen, stephen.dimilla, tom.ware
|
| Version: |
unspecified | |
|
| Target Milestone: |
--- | |
|
| Hardware: |
Macintosh | |
|
| OS: |
Mac OS X - Carbon (unsup.) | |
|
| Whiteboard: |
|
| Attachments: |
|
Build Identifier: eclipselink-2.3.0.v20110604-r9504 Using the following 2 entities: --------------------- @Cacheable(false) @Entity @Table(name="EMPLOYEE") public class Employee4 implements java.io.Serializable { private int id; private String firstName; private String lastName; private Date hireDate; private float salary; private Department department; public Employee4() { } public Employee4(int id, String firstName, String lastName) { this.id = id; this.firstName = firstName; this.lastName = lastName; } ... @ManyToOne @JoinColumn(name="FK_DEPT",insertable = false, updatable = true) public Department getDepartment() { return department; } public void setDepartment(Department department) { this.department = department; } --------------------- @Cacheable(false) @Entity @Table(name="DEPARTMENT") public class Department implements java.io.Serializable { // Instance variables private int id; private String name; public Department() { } public Department(int id, String name) { this.id = id; this.name = name; } --------------------- And the following client code: et.begin(); //insertable = false, updatable = true Employee4 empRef4 = new Employee4(8, "Thomas", "Brady"); empRef4.setDepartment(new Department(1, "Marketing")); em.persist(empRef4); em.flush(); et.commit(); ------------------------- I get the following output: [javatest.batch] [EL Fine]: 2011-12-07 10:47:33.92--ClientSession(1711465251)--Connection(1192380230)--Thread(Thread[main,5,main])--INSERT INTO EMPLOYEE (ID, HIREDATE, LASTNAME, SALARY, FK_DEPT) VALUES (?, ?, ?, ?, ?) [javatest.batch] bind => [8, null, Brady, 0.0, 1] Notice that the FK_DEPT value is being included. If I were to change the @JOINCOLUMN statement to: @JoinColumn(name="FK_DEPT",insertable = false, updatable = false) Then the output would be: [javatest.batch] [EL Fine]: 2011-12-07 10:47:33.92--ClientSession(1711465251)--Connection(1192380230)--Thread(Thread[main,5,main])--INSERT INTO EMPLOYEE (ID, HIREDATE, LASTNAME, SALARY) VALUES (?, ?, ?, ?) [javatest.batch] bind => [8, null, Brady, 0.0] Reproducible: Always