3 Replies Latest reply on Aug 7, 2008 10:29 AM by Siarhei Dudzin

    Simple Maven Seam + Hibernate Archetype

    Rob Hills Newbie

      Hi All,


      I'm trying to create a process that enables me to quickly build a simple Seam application with Persistence using Maven.  I want to use this to quickly test ideas and also as a resource for JIRA test cases.  I'm having trouble adding Persistence to an existing simple archetype.


      I've looked at a number of available Archetypes and Petr Ferschmann's JSF + Facelets + Seam Archetype mostly fits my needs, in that it quickly and easily produces a working Seam app, that runs in Jetty and has no extra entities/actions.  However, I also need to bring persistence into the mix and I'm struggling with that next step.  Petr's description of his archetype says that it excludes the persistence layer.  However, when I look through a project created using his archetype, it looks like all the basics are there.  However, I've tried a number of things but my Seam Configuration and Maven skills don't seem to be up to this.


      I've hunted through the Seam configuration documentation and also the JBoss Microcontainer documentation, but I'm just getting more confused.  I've also compared this with other Archetypes that include persistence layers, but there seem to be many different ways of configuring things and there are too many differences between the various archetypes for me to work out what to change.


      Has anyone successfully added persistence to Petr's Archetype?  If so, could you please share what you did?


      I've tried emailing Petr, but without any response yet.  If I can get this working, I'd like to use the knowledge to help add a simple JSF + Facelets + Seam + Persistence Archetype to those on Petr's site.


      TIA,

        • 1. Re: Simple Maven Seam + Hibernate Archetype
          Siarhei Dudzin Apprentice

          That blog is pretty old and there are no updates... You really might want to try those other alternatives... What exactly do you mean by 'adding persistence'?

          • 2. Re: Simple Maven Seam + Hibernate Archetype
            Rob Hills Newbie

            Hi Siarhei, thanks for the reply.


            By adding persistence I mean I'd like to be able to use a single maven command to build an in-memory db (eg HSQLDB) using any entities in my project, load it with sample data then fire up Jetty to run my Seam app.


            When I run the app I built with Petr's Archetype (mvn jetty:run) it seems to be actually building the DB, though not loading it up (AFAICT from the logs) but the app can't access it.  Not sure if that's because the persistence configuration in the app is slightly wrong somewhere or if it's totally cactus.


            • 3. Re: Simple Maven Seam + Hibernate Archetype
              Siarhei Dudzin Apprentice

              Most likely this is a persistence configuration issue. Make sure your persistence.xml (probably should be in src/main/resources/META-INF) contains hibernate.hbm2ddl.auto which has value 'create-drop' and you have import.sql with the insert statements (most likely should be in src/main/resources), those two conditions are mandatory for the database being built-up and filled with data.


              If you're talking about data fixtures for tests then refer to Seam reference.