I have an ember application with a Java Spring boot back end.
I tried the whole with simple objects and it worked fine. Now I wanted to make it a bit more complex like a real world scenario.
I have a clientDTO which looks like this
public class ClientDTO {
private PersonDTO personDTO;
private AddressDTO postalAddress;
private AddressDTO residentialAddress;
My ember Models look like this.
import DS from 'ember-data';
//client.js
export default DS.Model.extend({
person: DS.belongsTo('person', {async: false, inverse: 'client'}),
postalAddress : DS.belongsTo('address', {async: false}) ,
residentialAddress : DS.belongsTo('address', {async: true})
});
//address.js
export default DS.Model.extend({
line1: DS.attr('string'),
line2: DS.attr('string'),
postCode: DS.attr('string'),
suburb: DS.attr('string'),
client: DS.belongsTo('client')
});
//person.js
export default DS.Model.extend({
name : DS.attr('string'),
personName: DS.attr('string'),
identificationNumber: DS.attr('string') ,
client: DS.belongsTo('client', {inverse: 'party'})
});
I can define the address as an Arraylist with hasMany in the ember but that does not serve the purpose I need to have two different addressDTO objects bind with ClientDTO.
When I try to run the ember application and even load an empty /createNewClient form it gives me
ember.debug.js:17636 Assertion Failed: You defined the 'client' relationship on fo-ui@model:address:, but multiple possible inverse relationships of type fo-ui@model:address: were found on fo-ui@model:client:. Look at http://ift.tt/1aomJhS for how to explicitly specify inverses
Error
which is understandable, if i remove one of the addresses from the client.js model it works. So how can i have multiple models of the same model. As i understand there should be one 'address' model. i dont think i should need two address model one for residentialAddress and one for postalAddress. That would seem redundant.
Aucun commentaire:
Enregistrer un commentaire