vendredi 11 septembre 2015

Hibernate relations and AngularJS

I have this relation between Travelers and Trips in Hibernate:

enter image description here

If I want to create a new trip for traveler 1, I visit the route /frontend/#/trip-creation/1 and here I have a form:

enter image description here

By accessing the $routeParams.id I can get the details for traveler 1 like firstName (= Marcel) , lastName and also traveler_id.

$scope.traveler = TravelerFactory.show({id: $routeParams.id});

That is an example for the Traveler object. It contains all the Trips a Traveler had made so far:

[{"traveler_id":1,"company_id":0,"account":false,"firstName":"Marcel","middleName":null,"lastName":"Schmitt","gender":null,"trips":[],"email":null}]

My question:

  1. How can I relate my traveler 1 with the new created trip

    [{"trip_id":2,"traveler":null,"currency":null,"rate":100,"description":"Flug","dateCreated":null}]

  2. Is this a proper way of mapping the realtions?

Thank you!

Additional information // backend: Java, Hibernate 4.11, SpringMVC // frontend: AngularJS 1.4.3



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire