Package me.victorhernandez.hibernate.domain

Examples of me.victorhernandez.hibernate.domain.Person


        //printing events
        System.out.println("Event: " + theEvent.getTitle() + " Time: "
            + theEvent.getDate());
        for (int j = 0; j < persons.size(); j++) {
          //printing persons in each event
          Person thePerson = (Person) persons.get(j);
          System.out.println("Person: " + thePerson.getFirstname()
              + " " + thePerson.getLastname());
        }
      }
    } else if (args[0].equals("addpersontoevent")) {
      Long eventId = mgr.createAndStoreEvent("My Event", new Date());
      Long personId = mgr.createAndStorePerson("Foo", "Bar");
View Full Code Here


  private Long createAndStorePerson(String firstName, String lastName) {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();

    Person thePerson = new Person();
    thePerson.setFirstname(firstName);
    thePerson.setLastname(lastName);

    Long personId = (Long) session.save(thePerson);

    session.getTransaction().commit();
View Full Code Here

  private void addPersonToEvent(Long personId, Long eventId) {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();

    Person aPerson = (Person) session.load(Person.class, personId);
    Event anEvent = (Event) session.load(Event.class, eventId);
    aPerson.getEvents().add(anEvent);

    session.getTransaction().commit();
  }
View Full Code Here

 
  private void addEmailToPerson(Long personId, String emailAddress) {
        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();

        Person aPerson = (Person) session.load(Person.class, personId);
        // adding to the emailAddress collection might trigger a lazy load of the collection
        aPerson.getEmailAddresses().add(emailAddress);

        session.getTransaction().commit();
    }
View Full Code Here

  private Long createAndStorePerson(String firstName, String lastName) {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();

    Person thePerson = new Person();
    thePerson.setFirstname(firstName);
    thePerson.setLastname(lastName);

    Long personId = (Long) session.save(thePerson);

    session.getTransaction().commit();
View Full Code Here

  private void addPersonToEvent(Long personId, Long eventId) {
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();

    Person aPerson = (Person) session.load(Person.class, personId);
    Event anEvent = (Event) session.load(Event.class, eventId);
    aPerson.getEvents().add(anEvent);

    session.getTransaction().commit();
  }
View Full Code Here

TOP

Related Classes of me.victorhernandez.hibernate.domain.Person

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.