These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Is JPA discourages use of interface?
PostPosted: Wed Oct 22, 2008 1:27 am 
Newbie

Joined: Wed Oct 22, 2008 1:08 am
Posts: 1
Location: Surat, Gujarat, India.
Hello,
I am working in J2EE since last 3-4 months. Currently understanding (or i should say it learning) JPA.

As per my knowledge, JPA does not support use of interface(as a persistent attribute) in entity classes. I tried to get information about it, but in vain. Few people suggested to have a look at EclipseLink, but i am against using any vendor specific features.

FOR EXAMPLE--------------------------------------------------
Say Account is interface and SavingAccount and SalaryAccount classes are implementing Account interface.

Then class Client is having Account as a attribute. (named account)
so there will be statements like

private Account account;
public Account getAccount() {.........
public void setAccount(Account act) {.........


How to persist Client class??
----------------------------------------------------------------

And not using interface is bad practice, right?

As Erich Gamma said Program to an interface not to an implementation. Now that is not possible with JPA right?

I got many answer which tells me to use abstract classes . But it is not an option for interface.

So,
Is there any workaround?
What is your approach?
Or
People just accepted it.

-Nachiket

_________________
Objects are more important then classes.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.