3 Replies Latest reply on Sep 1, 2009 4:08 PM by luxspes

    Database views - best practice?

    dhcinc

      Are there any best practices to be used when dealing with database views in Seam? I have a number of views that need to be accounted for and have also seen a number of unique approaches to handling views as entities and want to tap into the user communities' experience on this issue.


      I was half hoping that there was a @View analog to the @Entity annotation.


      If it matters, the databases are SQL Server and Oracle using jdbc drivers.


      If this is really more of a Hibernate or JPA question, please let me know an I'll move the conversation over there.

        • 1. Re: Database views - best practice?

          We just use @Entity and define all the columns as updatable=false insertable=false and sometimes we fallback to spring-jdbc if appropiate. Another option also use sometimes is the Immutable annotation.


          But you should really take this discussion to the Hibernate Forum

          • 2. Re: Database views - best practice?
            caye

            So, if i understood well, we should make an Entity for each view in the database? Is it really the best option possible?


            Of course i understand that Seam and Hibernate are Entity-oriented, but maybe this is something that might be considered for a future for Seam because many times it is necesary to get data from a view in database and to have mixed entities that are tables in db with entities that are just views can lead to a confusion.

            • 3. Re: Database views - best practice?

              why? what kind of confusion?