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

  • SEARCH
  • Home
  • 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 3853790
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:31:24+00:00 2026-05-19T17:31:24+00:00

I am porting my Dao layer from KodoJDO to Hibernate. I am keeping my

  • 0

I am porting my Dao layer from KodoJDO to Hibernate.
I am keeping my menus in the database and based on a user’s entitlements I prune a local copy to display only what the user is allowed to do.

When I did this in KodoJDO I had to make the objest I was pruning transient because I didn’t want to write the changes back to the db.

I don’t see any equivalent function in Hibernate. Is there one? How do I keep these changes from getting written back to the db.

Here is the prune function.

 public void prune(Collection<Entitlement> ents)
 {
  Session session=PersistenceManager.getManager();
  // Rewrite----------------------------------
  //session.makeTransient(this);

  for (Iterator<Leaf> iter = leafs.iterator(); iter.hasNext();)
  {
   Leaf l = (Leaf) iter.next();
   if(!l.isAllowed(ents))
   {
    iter.remove();
   }
  }
  for (Iterator<Branch> iter = branches.iterator(); iter.hasNext();)
  {
   Branch b = (Branch) iter.next();
   if(b!= this)
   {
    b.prune(ents);
   }
   if (b.hasNoChildren())
   {
    iter.remove();
   }
  }
 }

Comment on answers. I accepted the one that was most complete, but the answers by skaffman and Affe were valuable as well.

  • 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-19T17:31:25+00:00Added an answer on May 19, 2026 at 5:31 pm

    In JPA 2.0 it’s entityManager.detach(..). I’m explicitly giving the JPA version, because it is advisable to use hibernate through JPA.

    If we look how is the detach(..) method implemented in hibernate’s EntityManagerImpl, it uses the getSession().evict(entity) on the underlying session

    But note that you should rarely need to do this. I don’t know whether it’s a common practice in JDO, but in JPA/Hibernate it is not needed if you are using them properly.

    As per your comment – if you want to use the hibernate entities as objects whose values you change but do not persist. I haven’t used them like that, because I usually don’t have an open session / entity manager in my view. Or I use value objects. If you both have an open session in the view, and you don’t have value objects – yes, this is a valid usage.

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

Sidebar

Related Questions

I'm porting the T6963-based LCD driver from AVR-GCC to the microchip C18 compiler. I
Im porting a project from php to java. The project is a web-app based
While porting data from one mysql database to another there have come some issues
I'm porting database schema tests from sql/plpgsql to Java/JDBC. But here is a test
I'm working on porting some ancient code (10.2 era) from NSCoding/plist based archiving to
Porting an application from C# (1.1 framework) to VB.NET (3.5 framework), and I have
Porting code from 32bit to 64bit. Lots of places with int len = strlen(pstr);
I am currently porting an application from iOS into Android and I have ran
I'm porting my game from WP7 to Android. My game is a kind of
After porting a code segment from Windows to Mac OS X, I found it

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.