3 Replies Latest reply on Jul 6, 2008 4:01 PM by serff

    Specifying table schema in orm.xml

    serff

      Hello,

      I'm trying to find a way to configure which schema my tables exist within an oracle database. I have a single entity that was hand generated (i.e. not by hbm, i did generate my tables off the entity).

      So far, I have found that you can specify the schema in the orm.xml, however, I cannot get this to work. I have tried:

       <persistence-unit-metadata>
       <persistence-unit-defaults>
       <schema>myschema</schema>
       </persistence-unit-defaults>
       </persistence-unit-metadata>
      

      and also specifying the schema attribute on the entity-mappings element. Neither seem to have any affect. I do not have anything else in my orm.xml. I have tried specifying my one entity by just doing
      <entity class="my.class.name"/>


      Does anyone have an example of how to do this or have any hints for me? Let me know.

      Is there a better way to do this (i.e. not the orm.xml)? I actually don't think the orm.xml is the best solution because it is packaged up in the ejb-jar. I would rather be able to specify the schema name outside of the application and load it at run time, however this seems impossible because the table name, etc are specified in the classes annotations. Hopefully someone knows a better way...

      Thanks!

        • 1. Re: Specifying table schema in orm.xml
          serff

          anyone?

          • 2. Re: Specifying table schema in orm.xml
            jaikiran

            Don't you specify the schema name in the datasource that you have configured for the persistence.xml?

            • 3. Re: Specifying table schema in orm.xml
              serff

              Yes you do, but that does not tell hibernate to prepend all the queries with the schema name.

              I have figured out how to make it prepend the schema to table names. My problem was my xml file was not named orm.xml exactally..i had oracle.orm.xml. didn't know it was that picky. So that fixed that problem. But now, it is not prepending the schema name to the sequences that I have. I believe this is a documented bug in hibernate, but I can't find it...

              I still don't think this solution is a very good one. There needs to be a way to configure this outside the deployable application. If anyone has accomplished this, i'd love to hear how.

              Thanks!