I have a one-to-many relationship but I'd like to get only one instance to have a one-to-one relationship.
I have a class vehicles that may have several owners throughout their life. I only want to map the class to obtain the assets. Is there some way to do this?
The problem is in the hbm.xml file. One vehicle may have several owners throughout their life but I want to obtain only the last owner. I need to filter by vehiculeId, ownerId and EndDate. I want to fill up object owner which is in vehicle.cs with the the assets.
When i write: Vehicule v = VehiculeService.SearchVehicule(id);
I'd like v.Owner must contain the last vehicle's owner.
I can't store the owner's ID on the vehicle table because the owner depend on the date. I can have for example: Vehicle Owner StartDate EndDate 1 1 04/04/2009 04/10/2009 1 2 05/10/2009 NULL
For this reason i must filter by EndDate to have the assets
I have three tables: Vehicle, Owner and OwnerVehicle. The problem is that i must a reference in vehicle.cs to the current owner. And i don't how to do the mapping.
Any help would be appreciated. Thanks