facebook

Trying to get Hibernate SessionFactory to execute custom sql

  1. MyEclipse IDE
  2.  > 
  3. Spring Development
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #313960 Reply

    philc
    Participant

    Scafolding CRUD application using MyEcllpse for Spring 8.6.1,
    Oracle 10g DB.
    New to Hibernate/JPA.

    I am trying to get a sequence from Oracle’s dual table (nextval) (i.e. “select SEQUENCE_NAME.nextval from dual”).
    I could only find how to execute custom sql through the current session via a SessionFactory.
    “… sessionFactory = new Configuration().configure().buildSessionFactory();”
    configure() by default looks for the hibernate.cfg.xml file that does not exist and I tried to use the dao application context.
    Can you point me to a direction towards resources that I could read to get this working using the set up that MyEclipse for Spring scaffolds? for example how to get the Session Factory based upon the scaffolded configuration.

    Thanks

    #313967 Reply

    philc
    Participant

    Please disregard my post. I reviewed the scaffolding results once again (including the JPA/Hibernate configs and annotations) and now see what I need to do.

    #313969 Reply

    philc
    Participant

    Ok, just when I thought it was safe to jump into the pool…
    Turns out I still haven’t been able to get the Hibernate Session so I can execute a custom query. Any information or direction is appreciated, sorry.

    #313978 Reply

    philc
    Participant

    Well got it work work one way by generating the hibernate.cfg.xml with db connection info then setting the session factory bean detail in the generated security context file. Seems a bit odd since the EntityManager has the datasource info already. Well I solved the problem one way, not sure its the best. Thanks.

    #314109 Reply

    jkennedy
    Member

    You may be able to replace this solution with the JPA annotations for dealing with DB generated values.
    Here is a decent review. http://www.objectdb.com/java/jpa/entity/generated

    Thanks,
    Jack

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: Trying to get Hibernate SessionFactory to execute custom sql

You must be logged in to post in the forum log in