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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:42:03+00:00 2026-06-13T03:42:03+00:00

I have defined an unowned relationship using JDO 3.0 syntax: @Persistent @Unowned private Set<Role>

  • 0

I have defined an unowned relationship using JDO 3.0 syntax:

@Persistent
@Unowned
private Set<Role> roles;

I have several predefined roles which should be assigned to users. I use following code for adding/removing roles to users:

roles.add(roleEntity);
roles.remove(roleEntity); 

The problem is that removing like this also removes the original entity from the datastore but I just want to remove the reference. I know I could store only Keys inside the parent entity which would solve the problem, but is there a better solution? Using this “natural” syntax?

  • 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-13T03:42:04+00:00Added an answer on June 13, 2026 at 3:42 am

    I guess this question deserves a real final answer.

    The described behavior was caused by a bug in JDO and it should be fixed by now. See http://code.google.com/p/datanucleus-appengine/issues/detail?id=290 for more details. Also notice, that owned relationships are always dependent, no matter what the documentation says.

    Unfortunately, it was fixed after I had moved back to JDO 2.0. In JDO 2.0, I implement unowned relationships using collections of keys or using foreign keys. And actually it’s not a bad solution so I don’t plan to try JDO 3.0 again. For a collection of keys I use batch fetch to get child objects, in case of foreign keys, I use simple queries with where statement. Sometimes it’s better to use the first solution, sometimes the second one. It’s all covered by a clean API anyway, so the final code is simple and “natural”. (I wish this approach was described directly in the documentation so we don’t have to learn it the hard way.)

    The important thing is that in both cases I can destroy the relationship without deleting original entities. It’s a true unowned relationship.

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

Sidebar

Related Questions

I have defined a syntax using treetop and most of the values parse fine,
I have defined one Thickness resource in Window's resources collection which is set to
I have defined a common lisp package using asdf which uses both parenscript and
I have defined the following class using COM to use the IGroupPolicyObject using C#.NET:
I have defined a ConfigurationProperty class, which is basicly a key-value pair (with key
I have defined the following method which calculates the average of an array: public
I have defined a JPA entity A with a @ManyToOne relationship to another JPA
I have defined a custom tag to take one parameter, a number, which it
I have defined a UITabBar programmatically but how can I set a custom UITabBar
i have defined a value using extern char WEBSRV_ADMIN_ID[31]; char WEBSRV_ADMIN_ID[31]= admin; then i

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.