Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

JPA: How to fetch primary key dynamically

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have been working with JPA from past few months.
Recently, I am involved in writing EJB3 statless bean, Interceptor & JPA.

Before manager's (statless bean's) method gets invoked, I am intercepting it through interceptor.

In my manager method, I am annotating some arguments (entities) as
a custom annotation.

In my interceptor, i need to check if that argument (entity) exists in Data Base or not.

For normal entites, i know, i can perform it like this:



But , I have more than 100 methods spread across some 10 - 15 managers ( with 30- 40 entities ) !
& I feel this will surely be a cross cutting concern ...


I have decided to go like this :



In My interceptor though, I get only
and i need to check if that object (which is actually entity) actually exists in a data base or not




Hope I am clear with my requirement ...

My questions are following: Is there a way in JPA API,

1) To check if the is an entity or not

2) To fetch the primary key dynamically from as

3) If above 2 do not exist, a way to check if entity exists in DB, in some other manner, which solves my requirement

Thanks a lottt

Thanks in advance .....

Waiting for your valuable response ...

Regds,

Vikas
 
You guys wanna see my fabulous new place? Or do you wanna look at this tiny ad?
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic