Hi there,

 I'm mapping my application to a database usinf JPA tags. I'm with the
following situation:

I have a class Product which has an attribute preferedShip, from the class
Ship.
In the interface, the user chooses a ship from a combobox. The combo lists
all the registered ships and two more options: ANY and NONE.

I have modeled ANY and NONE as static final objects of the type Ship,
because, like this I don't have to treat each case apart. Any and none are
Ships them.

Well, the problem is to persist this code. To save a product with
preferedShip as ANY or NONE I will have to reference one of the two objects.
But they are not persisted, because I modeled it as static final objects.
If I map it to the database I'll have to hard code an id in the objects.

Is this a good solution? Does anyone see any better solution?

thanks,
Luiz Fernando

Reply via email to