I have this schema:
--------------- -------------------- ----------------
| Customers | | CustomRoutePrice | | Route |
|-------------| |------------------| ---------------|
| CustId (pk) | | CustId (pk) | | RouteId (pk) |
| Desc | | RouteId (pk) | | Desc |
--------------- | Price | | Price |
-------------------- ----------------
and I want to map the CustomRoutePrice
's Price to my Customer
s POJO, saying something like:
Map<Route, Double> customRoutesPrices;
or maybe having a new POJO called CustomRoute
, so it may look something like this:
public class CustomRoute {
private Customer customer;
private Route route;
private Double price;
}
so within my Customer
s POJO I could have a set like:
Set<CustomRoute> customRoutes;
which may be the set of CustomRoute
s for that Customer
.
So my question is how can I make possible both mappings?
Thank you in advance.
You can declare a Map<Route,Double>:
<map name="customRoutesPrices" table="CustomRoutePrice">
<key column="CustId" not-null="true"/>
<map-key-many-to-many class="Route" column="RouteId"/>
<element column="Price" type="double"/>
</map>