Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3241240
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:10:33+00:00 2026-05-17T18:10:33+00:00

For security reasons, our oracle db objects normally belong to a different schema than

  • 0

For security reasons, our oracle db objects normally belong to a different schema than the logged in user. Eg. tables are in xx_core and the user we log in is xx_app_yy .
In my persistence.xml I define a orm file so that I can specify the schema name at deploy time eg.:
<mapping-file>xx_schema_orm.xml</mapping-file>

Then in the xx_schema_orm.xml I can define the object-owning-schema eg.:

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

This works great for tables, but I can’t find the equivalent for sequences. It tries to use the sequence without the schema name and then I get an exception:

2010-10-14 03:04:05,423:DEBUG   could not get next sequence value [select xx_SEQ.nextval from dual]     - org.hibernate.util.JDBCExceptionReporter
java.sql.SQLException: ORA-02289: sequence does not exist

    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:145)

I’ve tried to set the schema name as part of the sequence name for a generator in the xx_schema_orm.xml, but could not get it working eg.:

<sequence-generator name="xx_SEQ_GEN"
sequence-name="xx_core.xx_SEQ"/>

Workarounds I may try:

  • make a database SYNONYM for the sequences in the user’s schema.
  • stop using sequences and use some other way to generate ids.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T18:10:34+00:00Added an answer on May 17, 2026 at 6:10 pm

    In JPA 2.0:

    • the @SequenceGenerator annotation and the equivalent sequence-generator element do allow to specify a schema (and catalog) name.
    • the schema subelement should be honored by sequence generators as well.

    But this doesn’t apply to JPA 1.0.

    I’ll just quote the sections about the schema subelement to illustrate the differences (other relevant sections are mentioned in the references below). From the JPA 2.0 specification:

    12.2.1.1 schema

    The schema subelement applies to all entities, tables, secondary
    tables, join tables, collection
    tables, table generators, and
    sequence generators in the persistence unit.

    The schema subelement is overridden
    by any schema subelement of the
    entity-mappings element; any schema
    element explicitly specified in the
    Table or SecondaryTable annotation
    on an entity or any schema attribute
    on any table or secondary-table
    subelement defined within an entity
    element; any schema element
    explicitly specified in a
    TableGenerator annotation or
    table-generator subelement; any
    schema element explicitly specified in
    a SequenceGenerator annotation or
    sequence-generator subelement; any
    schema element explicitly specified
    in a JoinTable annotation or
    join-table subelement; and any
    schema element explicitly specified in
    a CollectionTable annotation or
    collection-table subelement.

    From the JPA 1.0 specification:

    10.1.1.1 schema

    The schema subelement applies to all
    entities, table generators, and join
    tables in the persistence unit.

    The schema subelement is overridden
    by any schema subelement of the
    entity-mappings element; any
    schema element explicitly specified
    in the Table or SecondaryTable
    annotation on an entity or any schema
    attribute on any table or
    secondary-table subelement defined
    within an entity element; any
    schema element explicitly specified
    in a TableGenerator annotation or
    table-generator subelement; and any
    schema element explicitly specified
    in a JoinTable annotation or
    join-table subelement.

    So, unless your provider offers some specific extensions, my suggestions are:

    • Upgrade to JPA 2.0 if possible and using the schema subelement will do the trick ~or~
    • Use a TableGenerator if you have to stick with JPA 1.0 ~or~
    • Use an alias if this is possible (I don’t know).

    References

    • JPA 1.0 Specification
      • Section 9.1.37 “SequenceGenerator Annotation”
      • Section 10.1.1.1 “schema”
      • Section 12.2.2.5 “sequence-generator”
    • JPA 2.0 Specification
      • Section 11.1.44 “SequenceGenerator Annotation”
      • Section 12.2.1.1 “schema”
      • Section 12.2.2.5 “sequence-generator”
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Obviously there are security reasons to close a wireless network and it's not fun
GWT's serializer has limited java.io.Serializable support, but for security reasons there is a whitelist
Our security manager dynamically inserts a bit of javascript at the top of every
For security purposes, is the primary identifier of an Active Directory user the 'logonname'
Is there a security limit to the number of Ajax XMLHttpRequest objects you can
Spring security has a nice feature, it remembers the url of request resource and
I'm wanting extra security for a particular point in my web app. So I
The .NET Security Policy can be changed from a script by using CasPol.exe .
During a discussion about security, a developer on my team asked if there was
The .NET System.Security.Cryptography namespace has a rather bewildering collection of algorithms that I could

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.