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 7865425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:04:59+00:00 2026-06-03T00:04:59+00:00

I’m trying to create a RESTful service. For multi tenancy I’m applying the @AdditionalCriteria

  • 0

I’m trying to create a RESTful service. For multi tenancy I’m applying the @AdditionalCriteria annotation. However, when I join an entity using the @OneToOne annotation the following Exception is raised:

Exception [EclipseLink-6174] (Eclipse Persistence Services - 2.3.0.v20110604-
r9504): org.eclipse.persistence.exceptions.QueryException
Exception Description: No value was provided for the session property 
[SECURITYID]. This exception is possible when using additional criteria or 
tenant discriminator columns without specifying the associated contextual 
property. These properties must be set through Entity Manager, Entity Manager 
Factory or persistence unit properties. If using native EclipseLink, these 
properties should be set directly on the session.
Query: ReadObjectQuery(name="readObject" referenceClass=Addresses 
sql="SELECT id, city, country, postalcode, province, security_id, street 
FROM addresses WHERE ((id = ?) AND (security_id = ?))")

I set the property [SECURITYID] at EntityManager level and without the join everything works just fine. But when I join an entity using the @OneToOne I see that property is not there. I don’t have enough experience to determine if this is caused by me doing something wrong or if this is a bug. To me it looks like a different EntityManager is used to fetch the joined entity. But I’m guessing because of me lacking in knowledge. I also tried to set the properties on EntityManagerFactory level but to no avail.

Here is my setup.
Entity:

@Entity
@AdditionalCriteria("this.securityId=:SECURITYID")
@Table(name = "tasks", catalog = "catalog", schema = "schema")
@XmlRootElement
@NamedQueries(
{
  @NamedQuery(name = "Tasks.findAll", query = "SELECT t FROM Tasks t")

})
public class Tasks implements Serializable
{
...
  @OneToOne(fetch=FetchType.EAGER)
  @JoinColumn(name="service_address_id")
  private Addresses serviceAddress;

...
}

RESTFacade class

@Stateless
@Path("tasks")
public class TasksFacadeREST extends AbstractFacade<Tasks>
{
  @PersistenceContext(unitName = "UnitName")
  private EntityManager em;

...

  @java.lang.Override
  protected EntityManager getEntityManager()
  {
    // Temp! REMOVE WHEN DONE
    sessionId = "123456789";

    Identifier.setIdentity(em,sessionId);
    em.setProperty("SECURITYID",Identifier.securityId);
    em.setProperty("USERID",Identifier.userId);

    return em;
  }

Thanks & Rgds,
M

  • 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-06-03T00:05:00+00:00Added an answer on June 3, 2026 at 12:05 am

    My guess is this is related to caching.

    Normally the tenant property would be set on the EntityManagerFactory, not the EntityManager. This would mean you have a different EntityManagerFactory for each tenant. You could also define the tenant property in your persistence.xml and have a different persistence unit per tenant.

    If you need to set the tenant per EntityManager, then you need to disable the shared cache, or setting the cache mode to protected.

    http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Single-Table_Multi-Tenancy#Setting_Properties_and_Caching_Scope

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.