Best implementation method

View: New views
3 Messages — Rating Filter:   Alert me  

Best implementation method

by measwel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello guys,

I am trying to read a collection of countries (Strings) into a collection inside a Movie object. The countries reside in a separate DB table with a FK referencing the Movie.

My questions:
1) What is the best way to implement this? Do I need an entity 'country' ? Is there a general way to read many strings into a collection?

2) the countries list does not have to be updated, only read. How do I make sure it is not persistent?

I have noticed that in my JPA implementation (in netbeans) I do not have something like CollectionOfElements (that is present in hybernate).

Thank you,
Marek

Re: Best implementation method

by James Sutherland :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

JPA 1.0 does not define a mapping for a collection of basic types.  This will be defined in JPA 2.0 using the @ElementCollection mapping.

If you are using TopLink / EclipseLink as your JPA provider you can use the @BasicCollection mapping for this.  Otherwise, you can create a Country object (you might need one eventually anyway).

Re: Best implementation method

by measwel :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thank You. Creating a seperate country entity indeed solved the problem.