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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:07:37+00:00 2026-05-23T15:07:37+00:00

I have sceneario in which I have to check if an onject instance exist

  • 0

I have sceneario in which I have to check if an onject instance exist in entity manager. It works fine when the instance eexists but throws null pointer exception when it doesn’t. When it doesn’t I have to do another thing. so how can catch this state? I already tried try catch, but it doesn’t work.

Sorry when I was asking this question I was on the way and trying to type in a different device that I am used to. My code is:

AJPAController aJPAController;
AClass aClass = aJPAController.find((Integer.parseInt(request.getParameter("id")));

try{
    if(aJpaController.contains(aClass)){
       response.sendRedirect("gosomewhere.com");
     }
}
catch (java.lang.NullPointerException R){
     response.sendRedirect("gosomewhereelse.com");
}

I might have a logical mistake in trying first find and then contains method, but I couldn’t find a better solution.
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-05-23T15:07:38+00:00Added an answer on May 23, 2026 at 3:07 pm

    You can check if an entity is managed (within the persistence context) with help of the contains method of your EntityManager

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

Sidebar

Related Questions

I have a scenario in which I'm serving a file from codebehind. which file,
I have a scenario in which I have REST API which manages a Resource
we have this scenario: A server which contains needed data and client component which
I have a scenario in a system which I've tried to simplify as best
I have a scenario. (Windows Forms, C#, .NET) There is a main form which
Scenario I have a DevExpress DataGrid which is bound to a DataSet in C#.
Scenario 1: I have one wrapper Perl script which uses another Perl module and
The scenario is this We have two applications A and B, both which are
I am having a scenario, in which i have multiple delegates attached to the
This is a very common scenario: displaying images in a ListView which have to

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.