Results 1 to 3 of 3

Thread: How to get Hibernate Session ?

  1. #1
    Join Date
    Dec 2011
    Posts
    28

    Question How to get Hibernate Session ?

    Hi,

    I have a Spring MVC project where a dataSource is configured in the following files:


    • META-INF/spring/applicationContext.xml
    • META-INF/spring/database.properties
    • META-INF/persistence.xml


    The dataSource seems to be set up correctly, since Hibernate creates the tables on Tomcat start-up.

    In my previous Hibernate projects (which were not Spring-based) I used to have the famous HibernateUtil Class which I could get a Hibernate Session from, and do my database-related work.

    Obviously HibernateUtil is not needed any more with Spring...

    But how can I get the Session?

    Edit: Or should I go for EntityManager? If yes, how can I get an instance?

    Best regards,
    Yves
    Last edited by yglodt; Mar 4th, 2012 at 02:49 PM.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    I suggest the reference guide which explains this in quite some detail. you want to read the chapter about hibernate and especially the part about implementing plain hibernate daos.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Dec 2011
    Posts
    28

    Default

    Thanks for the guidance!

    I am currently reading http://static.springsource.org/sprin.../html/orm.html, chapter 13.3 seems to be what I need.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •