Announcement Announcement Module
Collapse
No announcement yet.
Using home classes of Hibernate Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using home classes of Hibernate

    Hi,
    I use the reverse engineering with hibernate, everything works well with classes but I wanted to add the class home generated automatically with hibernate tools and use its methods. this is the method:
    Code:
    public void attachDirty(NeGroup instance) {
    		log.debug("attaching dirty NeGroup instance");
    		sessionFactory.getCurrentSession().beginTransaction();
    		try {
    			sessionFactory.getCurrentSession().saveOrUpdate(instance);
    			log.debug("attach successful");
    		} catch (RuntimeException re) {
    			log.error("attach failed", re);
    			throw re;
    		}
    	}
    and here is my main:
    Code:
    NeGroup NG = new NeGroup();
    		NG.setNeGroupId(5);
    		NG.setName("Mohamed");
    		NG.setDescription("is smart");
    		NeGroupHome NG1 = new NeGroupHome();
    		NG1.attachDirty(NG);
    I just want to add a row into the table. the logs said that:
    12:50:07,979 DEBUG NeGroupHome:48 - attaching dirty NeGroup instance
    12:50:08,084 DEBUG NeGroupHome:52 - attach successful
    but nothing happens to the table !!

  • #2
    I guess you need to either commit or flush the session.

    Comment

    Working...
    X