Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 1st, 2012  |  syntax: None  |  size: 0.97 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Eclipselink merge fails to generate UPDATE statement for changed value
  2. public class A {
  3.     ...
  4.     @Id
  5.     @Column(name = "A_ID")
  6.     @SequenceGenerator(...)
  7.     @GeneratedValue(...)
  8.     public Long getA_ID();
  9.  
  10.     @OneToOne(mappedBy = "a", fetch = FetchType.LAZY, cascade = CascadeType.ALL, targetEntity = B.class)
  11.     public B getB();
  12.     ...
  13. }
  14.  
  15. @VirtualAccessMethods(get = "getMethod", set = "setMethod")
  16. public class B {
  17.     ...
  18.  
  19.     @Id
  20.     public Long getA_ID();
  21.  
  22.     @MapsId
  23.     @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL ,targetEntity = A.class)
  24.     @JoinColumn(name="A_ID")
  25.     public A getA();
  26.  
  27.     getMethod(String name);
  28.  
  29.     setMethod(String name, Object value);
  30.     ...
  31. }
  32.        
  33. @Transactional
  34. public void update(Object fieldOnANewValue, Object fieldOnBNewField) {
  35.     A objA = em.executeQuery(...) //loads objA by primary key
  36.     objA.setFieldOnA(fieldOnANewValue);
  37.     B objB = objA.getB(); //lazy loads objB
  38.     objB.setMethod("FieldOnB", fieldOnBNewValue);
  39. }