1

I am working on one application using JPA orm. I need to set default schema in persistence.xml. I got some refence and added properties for default schema which is not working. It is probably some syntax issue or some more mapping\configurations which I am unaware.

Please let me know if any pointers to resolve this issue.

<properties>
    <property name="openjpa.RuntimeUnenhancedClasses" value="supported" />
    <property name="openjpa.jdbc.Schema" value="XY01" />
    <property name="hibernate.default_schema" value="XY01" />
</properties>
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Tokendra Kumar Sahu
  • 3,524
  • 11
  • 28
  • 29
  • The JPA standard file `orm.xml` clearly has a section *persistence-unit-defaults* where you can set the schema. http://xmlns.jcp.org/xml/ns/persistence/orm_2_2.xsd Then there is no need to faff about with JPA provider extensions (and why you would refer to OpenJPA, as well as Hibernate I'm not sure). –  Aug 08 '18 at 14:00
  • 1
    Possible duplicate of [How to set up default schema name in JPA configuration?](https://stackoverflow.com/questions/2737420/how-to-set-up-default-schema-name-in-jpa-configuration) – Lorelorelore Aug 08 '18 at 14:01
  • I mentioned OpenJPA and Hibernet both just to show that I tried both. And I am not using Spring or Hibernet in my project. – Tokendra Kumar Sahu Aug 09 '18 at 05:06
  • What does "not working" mean? What schema is *actually* used when you are using ``? Is there a command-line override? If you are using an IBM-supplied driver, have you tried appending to the URL `currentSchema="XY01"`? If still not resolved then edit your question to give more facts (versions of products, platforms, driver supplier details etc). – mao Aug 09 '18 at 16:26
  • We were referring the existing code base, Hence using the OpenJPA. – Tokendra Kumar Sahu Feb 08 '19 at 11:03
  • This was part of a migration task. Issue wasn't resolved but this is no longer required. Thanks for the help guys. – Tokendra Kumar Sahu Feb 08 '19 at 11:05
  • I'm voting to close this question as off-topic because this is no longer required – Tokendra Kumar Sahu Feb 08 '19 at 11:06

1 Answers1

3

Try to set the property in your persistence.xml file, as follows:

    <properties>
        <property name="hibernate.default_schema" value="myschema"/>
    </properties>
Peter
  • 399
  • 2
  • 6
  • 23