Announcement Announcement Module
No announcement yet.
Reverse Engineer DB View with Spring Roo Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Reverse Engineer DB View with Spring Roo


    I am using roo for a project with an existing DB. I've attempted to reverse engineer a view which works, but I can't figure out how to call it or use it.

    It creates two sets of files: (and supporting files) (and supporting files)

    I try to make a finder like:


    And that never works.

    Reading the in the Roo documentation, it indicates that views should not be used except for specialized use cases (what ever that means).

    So, question 1, should I be using views and if so, how do I use them and create a finder? (As stated below, I'm trying to use the finders it creates by default, and they just return lists of nulls. I've manually created a finder, and it also returns a list of nulls).

    Question 2, if views are not to be used, how can I do a simple table join so that I don't have to get all of the properties from all of the joined tables? I'm only interested in a few columns from each and to do multiple queries seems like a waste of cycles.....

    In executing the find all method, it returns a List with the right number of items, but all items are null. Obviously, I'm not doing something right.

    Last edited by mrbahr2003; Sep 27th, 2011, 02:10 AM.

  • #2
    I probably wouldn't use views with Roo's scaffolded JPA infrastructure. It's not so much a Roo problem but more of a JPA issue. Persisting an entity to a view will be problematic with various databases, and some don't support it at all.

    For Q2, DBRE does not, by design, limit what coiumns are reverse engineered, given that they could be FK references to other tables. My suggestion is that once you have reverse engineered your DB, edit the dbre.xml file and carefully delete all the fields you don't want, or push-in refactor all the fields and methods from the DbManaged ITD for that entity and remove the @RooDbmanaged annotation from the class.
    Last edited by Alan Stewart; Sep 27th, 2011, 07:34 PM.