Unlike Hibernate itself, Breeze requires foreign keys that are mapped to object properties so Breeze can maintain the relationships on the client side. Here’s an example, mapping a relationship from Order to Customer:
<many-to-one name="Customer" column="`CustomerID`" class="Customer" />
<property name="CustomerID" type="System.Guid" insert="false" update="false" />
The “Customer” property is mapped normally, while the “CustomerID” property is mapped with insert="false"
and update="false"
. This way, the CustomerID is exposed to Breeze, but Hibernate will perform inserts and updates using the ID of the Customer object itself.
Foreign keys are required on the client for Breeze to work. They are also required to re-connect the entities on the server during the SaveChanges processing. However, we should be able to generate the keys automatically, without having to map them in the model. Our plan is to:
Note that this is closely tied to the JSON serialization process.
Currently, breeze-hibernate
supports the entire spectrum breeze query and save capabilities with the exception of:
{ where: { ‘month(birthDate)’: { gt: 3}}}
{ where: { companyName: { startsWith: ‘B’ } }, select: ‘orders’ }