From: Jack C. H. (JIRA) <no...@at...> - 2006-07-13 19:16:56
|
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1906?page=comments#action_23627 ] Jack C. Holt commented on HHH-1906: ----------------------------------- I suggest that the following method be modified as follows: private Long createAndStoreEvent(String title, Date theDate) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); Event theEvent = new Event(); theEvent.setTitle(title); theEvent.setDate(theDate); session.save(theEvent); Long eventId = theEvent.getId(); session.getTransaction().commit(); return eventId; } ... and that the following method be added. private Long createAndStorePerson(String firstName, String lastName) { Session session = HibernateUtil.getSessionFactory().getCurrentSession(); session.beginTransaction(); Person thePerson = new Person(); thePerson.setFirstname(firstName); thePerson.setLastname(lastName); session.save(thePerson); Long personId = thePerson.getId(); session.getTransaction().commit(); return personId; } > Incorrect code in Hibernate 3.1.1 Reference PDF > ----------------------------------------------- > > Key: HHH-1906 > URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1906 > Project: Hibernate3 > Type: Bug > Components: documentation > Versions: 3.1.1, 3.1.2, 3.1.3 > Environment: N/A > Reporter: Jack C. Holt > > > the last code snippet in section 1.3.3 on page 13 shows the following code: > Long eventId = mgr.createAndStoreEvent("My Event", new Date()); > Long personId = mgr.createAndStorePerson("Foo", "Bar"); > Both methods are defined as returning void, not Long. Therefore, the code causes a compiler error. > The code snippet is also missing a closing "}". -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |