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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:06:35+00:00 2026-06-02T11:06:35+00:00

Given a Hibernate domain object, is there some way I can determine if it

  • 0

Given a Hibernate domain object, is there some way I can determine if it is live (i.e. exists in the database) other than searching for it? Is there some method a la HIbernate.isObjectLive(domainObj) or domainObj.amIAlive() that might be more efficient?

I’m relatively new to Hibernate. If “no” is the answer, I’m ok with that. Thanks in advance.

  • 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-02T11:06:36+00:00Added an answer on June 2, 2026 at 11:06 am

    Hibernate would only know whether an object is ‘live’ by that definition by checking the database. You should use Session.get(object.getClass(), object.getId()) to see if that’s the case. It’ll return null if the object no longer exists in the database.

    Be aware that the Session has a cache, so if the object is in that cache already, but in the meantime has been deleted from the database, Session.get(...) will return a reference. For this reason you may want to get a new Session before doing the check.

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

Sidebar

Related Questions

Can hibernate resolve mapping across more than one table. Here is example: Class Manufacturer,
Given a package, how can I automatically find all its sub-packages?
Given an interface or interfaces, what is the best way to generate an class
i'am writing some swing applications(not rich clients, running standalone) with a lot of domain
Given example from Hibernate docs and modifying it so that root level entity (Customer)
I want to do something like this in my domain/entity object : @Entity @NamedQueries({
Given the following domain model: Dog { Id, Name, Color } Color { Id,
I would like to query using hibernate given a particulay query string I did
Given an entity class with a compound key that is managed by hibernate is
I tried Hibernate Mapping Many-to-Many using Annotations with the example given in vaannila. http://www.vaannila.com/hibernate/hibernate-example/hibernate-mapping-many-to-many-using-annotations-1.html

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.