Page 1 of 5 123 ... LastLast
Results 1 to 10 of 43

Thread: Using Roo with an existing database

  1. #1

    Default Using Roo with an existing database

    I have an existing database that I have to write a simple web based CRUD application for. I'm considering using Roo. The problem I've seen so far is that Roo wants to create it's own database based on the domain objects. Is there or is there going to be a reverse mapping? Something like this exists in Django:
    http://docs.djangoproject.com/en/dev...gacy-databases

    I think it's very useful because in most corporations the data already exists in some relational form and it's the applications that change or get replaced.

    Thanks,
    Martin

  2. #2
    Join Date
    Mar 2008
    Location
    Sydney, AU
    Posts
    974

    Default

    Hi Martin,

    This feature is currently not supported as we have not yet seen demand for it. Are you interested in developing such an add-on? We would certainly be available to guide you with any questions that should arise.

    In the meantime you will notice that the current 'entity' and 'field' command options offer you the ability to create custom mappings between type field names and table names and column names, etc.

    -Stefan

  3. #3
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    This is a good example of a third-party add-on. It's quite easy to introspect database metadata via JDBC and drive the Roo Operations objects that are responsible for entity creation.
    Ben Alex
    Project Founder, Spring UAA, Spring Roo and Spring Security

  4. #4

    Default

    Thanks.

    I may do it in the future but at the moment I have to get this project working first.

  5. #5
    Join Date
    Oct 2005
    Location
    Mobile, AL
    Posts
    345

    Default Interested

    I am interested in this as well. I will start working on a addon to be able to generate entities from a given db schema. I am sure I will have questions along the way.

    I will keep you guys posted.

    Marty

  6. #6

    Default Configuring Roo with an existing DB

    The problem I currently have is that in my existing database I don't have the version (required by Roo) on my tables. Is it something that can be solved only by adding the version column to every table in the existing schema?

    Also, when I map a Roo entity to an existing table with an already existing primary key (--identifierColumn / --identifierField) there is no option for defining a finder on that column.

    Is there a way to enforce foreign key relationships with Roo?
    Last edited by martin.gercsak; Oct 27th, 2009 at 12:01 AM.

  7. #7
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    If you use @RooEntity and set the identifier column and identifier field attributes correctly, the findById() method will automatically use that column.

    Re the version field, this is optional. You can set in @RooEntity the version field name to "" and it will be ignored. Or you can go and create a version column instead in the database and it'll work.
    Ben Alex
    Project Founder, Spring UAA, Spring Roo and Spring Security

  8. #8

    Default Defining a Foreign Key

    But what about the foreign key relationships? Ideally you would define a foreign key relationship and then would have a drop down menu in the UI with the possible values. I understand that this is a bit futuristic to have it generated but is there any way to achieve something similar? What I don't want is to have this FK relationship enforced only in the database and find out about it being violated via jdbc exceptions.

    What I can currently think of is modifying the JSPs and the controllers manually to fill in the valid values. The problem with this approach is that the jspx files are generated so you loose a lot of backwards compatibility and if you modify the entity you have to do it again. Would you suggest in this case to just switch to a static jsp for that view?

  9. #9
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    Sorry, I'm not really understanding the problem in the first place. If you have say an Order and a LineItem entity, there will be a FK relationship. The scaffolded web view for LineItem will require an Order to be selected and therefore satisfy the FK relationship. Am I missing something?
    Ben Alex
    Project Founder, Spring UAA, Spring Roo and Spring Security

  10. #10

    Default

    Quote Originally Posted by Ben Alex View Post
    If you use @RooEntity and set the identifier column and identifier field attributes correctly, the findById() method will automatically use that column.

    Re the version field, this is optional. You can set in @RooEntity the version field name to "" and it will be ignored. Or you can go and create a version column instead in the database and it'll work.
    This doesn't seem to work:
    roo> finder add --finderName findById --class au.gov.rba.dtcc.domain.Country
    [Main Thread] The finder name 'findById' contains an error
    [Main Thread] Dynamic finder is unable to match 'findById' token of 'findById' finder definition in Country.java

    The definition I have is this:
    @RooEntity(identifierField = "countryid", finders = { "findCountrysByCountrynameLike" })

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
  •