Results 1 to 2 of 2
  1. #1
    flanjl2 is offline Member
    Join Date
    Aug 2011
    Posts
    21
    Rep Power
    0

    Question persistence NULLs

    working with eclipselink drivers, unable to sucesfully input data into the OneToOne entity relationships..though able to see the one to one relationship in the table view(s). Able to see parent entity's data...any sugestions?

    CODE::::::

    package PERSISTENCE.OnetoOne;

    import javax.persistence.*;


    @Entity
    public class Customer {
    @Id @GeneratedValue(strategy=GenerationType.SEQUENCE)
    private Long id;
    private String name="JF";
    private String personality="unknown";
    private String aptitudes="Up in the Air...";
    @OneToOne(fetch= FetchType.EAGER)
    @JoinColumn(name="address_fk")
    private Address1 address1;

    Customer(){}

    @Entity
    @Table(name= "Address Table")
    public static class Address1 {
    @Id @GeneratedValue(strategy=GenerationType.SEQUENCE)
    private Long id;
    private String location="JNormandy";


    Address1(){this.location="JNormandy";}
    }


    public static void main(String[] args) {
    Customer customer= new Customer();
    EntityManagerFactory emf= Persistence.createEntityManagerFactory("chapter03P U");
    EntityManager em= emf.createEntityManager();
    EntityTransaction tx= em.getTransaction();
    tx.begin();
    em.persist(customer);
    tx.commit();
    tx.begin();
    em.close();
    emf.close();
    }

    }

  2. #2
    flanjl2 is offline Member
    Join Date
    Aug 2011
    Posts
    21
    Rep Power
    0

    Default Re: persistence NULLs

    Must add a cascadeTYPE option to the "onetoone" annotation....
    @OneToOne(fetch=FetchType.EAGER, cascade=CascadeType.ALL);
    .................................................. ............

Similar Threads

  1. Persistence API with Java SE?
    By FlyNn in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 02-14-2012, 10:47 PM
  2. Persistence
    By frexjeff in forum Advanced Java
    Replies: 1
    Last Post: 01-21-2011, 04:03 PM
  3. help me with persistence
    By halyal in forum NetBeans
    Replies: 14
    Last Post: 09-04-2010, 10:20 AM
  4. Persistence technology
    By Hugo in forum AWT / Swing
    Replies: 6
    Last Post: 05-09-2010, 12:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •