Announcement Announcement Module
No announcement yet.
Hibernate one to one Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hibernate one to one

    Hi guys

    another question. I can see that roo supports one to many relationships in hibernate.

    how about one to one?

    also is there a way to create the sql scripts from the entity objects?

    Thank you

  • #2

    To create a relationship you could use the 'add field reference jpa -type -fieldName myPet -class'. This will generate a field like this in

    private Pet myPet;
    We are reviewing if it makes more sense to use JPA's @OneToOne relationship instead.

    also is there a way to create the sql scripts from the entity objects?
    I am not clear what exactly you are trying to do. But if you want to create your own query you could just use the JPA entityManager which is already existent in your JPA @Entity:

    public List<Owner> test(){
       return entityManager.createQuery("select p from Owner p").getResultList();
    Is this what you are referring to?



    • #3
      Hey Stefan

      thanks for the answer.

      The second part was more about if i can create "table statements" like create table Owner (id auto_increment int primary key, name varchar(50))

      from roo and its managed entities...


      btw where are you guys located? you have a very german name


      • #4

        For the feature of executing SQL scripts upon application deployment you can take a look at the petclinic samples in Spring framework. They create tables and pre-populate the tables upon application start if that is what you are referring to. In the upcoming Spring 3 release we will also include a new feature which let's you configure that very conveniently for embedded databases via the application context.

        Ben and I are based in Sydney, Australia, but indeed I am German .



        • #5
          Nice thank you... i will take a look at those samples...