Spring,Primefaces,Hibernate: Save action is called automatically when I hit the create url -


i trying show form , save it. using spring + primefaces , hibernate.

the problem when try hit url drs/jsf/lodi/createlodi.xhtml, expecting show form create entity. happening first calling savelodi() method , creates record in database.

i don't know causing so. here createlodi() method

@transactional(readonly=true) public string newlodi() {     lodi = new lodi();      return "/jsf/lodi/createlodi.xhtml"; } 

and here savelodi()

/**  * save existing lodi entity  *   */ @transactional public string savelodi(lodi lodi) {     system.out.println("savelodi called...........!");     lodiservice.savelodi(lodi);     return "/jsf/lodi/listlodis.xhtml"; } 

and calling menuitem of menubar component

    <p:menuitem value="enter , update 807's" url="#{lodicomponent.newlodi()}" ajax="true"/> 

what wrong it? why save being called? can give me idea?

thanks, tahir

this error how transactions set , or flushmode use.

the question happens between createlodi , savelodi method? when make hibernate call entity or still have other ongoing transaction query or commit there might trigger flush() when have set on flushmode.auto (which default).

http://docs.jboss.org/hibernate/orm/3.5/javadoc/org/hibernate/flushmode.html

the clean solution set transaction in way createlody , savelodi in 1 transaction. hibernate handle entity saved in db when transaction ended without error or abort. enable set transaction how need it.


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -