Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.

JPA (Java Persistence API) Question

  • 17-04-2009 03:40PM
    #1
    Registered Users, Registered Users 2 Posts: 15,443
    ✭✭✭✭


    On the offchance there's a JPA crack here...

    We're using JPA in a Java EE application, using annotations (as opposed to an orm.xml). DB at the back-end is Oracle. JPA Provider is EclipseLink.

    Its all groovy and stuff, except...

    For various reasons, we need to reference tables which are in a schema other than that of the logged-in user.

    There are a number of ways I can see of doing this...

    Oracle-side, I can do one of two things:

    1) I can specify SYNONYMs in the DB, so that I can refer to objects
    without a schema qualification.
    2) I can have an after_logon trigger to SET CURRENT_SCHEMA what I want.

    For various reasons based on how our systems are run, the latter isn't allowed, and the former would involve quite a lot of work.


    Java-side, I also have at least two options:

    1) Add the schema-name to the @Table annotation.
    2) Abandon annotations, and use an orm.xml

    Again, neither of these are grabbing me.

    Can anyone see another option that I'm missing?


Comments

  • Registered Users, Registered Users 2 Posts: 15,443 bonkey
    ✭✭✭✭


    So...just in case anyone else uses JPA...

    in orm.xml, I can set persistence-unit-defaults, including a schema. These are also applied to the annotation-based approach.

    The only "cost" is that it doesn't use the schema in SequenceGenerators, so I had to switch to TableGenerator instead.


Welcome!

It looks like you're new here. Sign in or register to get started.
Advertisement