开发者

Hibernate Session

I am using Seam + EJB + JPA + Hibernate and JbossAS6 as my application server. I have to convert JPA code to hibernate, On deployment i get the following error.

2011-07-06 01:49:15,122 ERROR [org.jboss.kernel.plugins.dependency.AbstractKernelController] (HDScanner) Error installing to PostClassLoader: name=vfs:///opt/jboss6/server/default/deploy/SMS-ear.ear state=ClassLoader mode=Manual requiredState=PostClassLoader: org.jboss.deployers.spi.DeploymentException: Exception while loading interceptor classes for unit vfs:///opt/jboss6/server/default/deploy/SMS-ear.ear/SMS-ejb.jar/

Heres what i changed in the original working code : Orignal code :

   Query userQuery = em.createSQLQuery("select u.username from User u where u.username=#{user.username}");
   List existing = userQuery.getResultList();
    List existing = userQuery.getResultList();

Modified Code:

     org.jboss.ejb3.entity.HibernateSession hs = (HibernateSession)entityManager;
     org.hibernate.Session em = hs.getHibernateSession();
    log.info("Hibernate session"+em);

     List existing = em.createSQLQuery("select u.username from User u where u.username=#{user.username}").list();

I want to get hibernate Session in my application I am quite new to JPA. I am stuck with this problem. Is this the right way to get a session?

Regar开发者_如何学Gods Jamshed


It seems seam is allowing this query syntax (which is odd). Your exception seems unrelated to the change.

  • revert the change and make sure it starts working again
  • clean the environment
  • restart

Original answer:

WHERE u.username=:username

and then query.setParameter("username", user.getUsername())

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜