2013年12月8日星期日

spring_hibernate integration problems encountered by novice really do not know how to solve , find great God pointing, online

Novice learning ssh, find online video learning , problems encountered when learned spring_hibernate
Find Great God look
------ Solution -------------------------------- ------------
of the mother. . . . . . . . .
------ Solution ---------------------------------------- ----
whether Hibernate dialect configuration not
------ Solution -------------------------- ------------------
first, in the spring configuration file applicationContext configured :
<-! declarative transaction management - >
class = "org.springframework.transaction.interceptor.TransactionInterceptor">





PROPAGATION_REQUIRED
PROPAGATION_REQUIRED, readOnly



<-! declarative transaction management end - >

Then dao transaction management configuration you want to use :




<-! declarative transaction management configuration DAO ->
class = "org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">


UserDao




proxyTemplate



After
UserDao will be used as long as the getHibernateTemplate () save (user);. methods can be named saveXXX
can try this way , just to check in online , you want to help, and have time to look Keguan Chi Chuan broadcast online . NET video , which explains the very thorough
---- - For reference only ---------------------------------------

public void save (User u)
{
Session s = sessionFactory.openSession ();
s.beginTransaction ();
s.save (u);
s.getTransaction () commit ().;
System.out.println ("user save!");
} This is my save method is to deposit does not go ah, null values ​​can not I? Used SQL2005
------ For reference only ----------------------------------- ----
issue is resolved, do not pay attention to some details of his own , thank you upstairs pro

没有评论:

发表评论