Results 1 to 3 of 3

Thread: Spring Roo and Database

  1. #1

    Default Spring Roo and Database

    Hello,
    I am totally new to Roo. I have read some introduction of Roo and tried a small example to generate code using Hibernate. I still have some basic questions related to it.
    I already have an existing database in MYSQL. How can I map the tables with the entities in Roo using Hibernate?
    It looks like Roo engineers the database at runtime but I am unable to get this concept and am confused on what do we do if we have an existing database.
    If Roo creates the ddls and executes them how do we define the table integrities, index etc? I tried to see a lot of examples but am unable to get the actual concept.

    Thanks in Advance.
    Nitin

  2. #2
    Join Date
    May 2006
    Location
    Madrid
    Posts
    382

    Default

    Reverse engineer.

    After:

    Code:
    persistence setup --database MYSQL --provider HIBERNATE --userName XXX --password XXX
    (Or editing the database.properties instead of passing the database user and password)

    Try:

    Code:
    database reverse engineer --schema PUBLIC --package ~.domain
    Using the appropriate schema and the desired package.

    If it fails, because Roo needs the driver to connect to the database, Roo will locate an addon for doing so. Just follow the instructions, basically you'll have to do something like this:

    Code:
    addon install id --searchResult 01
    Being 01 the first addon that Roo has found.

    Note: Roo doesn't create any ddl, Roo generates JPA code and therefore the database can be created, validated and so on.

    Find the next line within the persistence.xml:

    Code:
    <property name="hibernate.hbm2ddl.auto" value="validate"/>
    If you already have the entities, you can set value to create and the JPA engine (Hibernate, for instance) will create the tables.

    To achieve database definition, the JPA annotations are used (@Entity, @ManyToOne, @JoinColumn...), but I don't know if you can create all the database stuff (indexes, for instance) with JPA. If it's not possible (try the documentation) you will have to modify the database using its own commands (MySQL in your case)

  3. #3

    Default

    Thanks a lot for the reply. I'll try that out. Thanks again for that helpful information.

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
  •