boyenn / hbc-twilio

Apache License 2.0
1 stars 0 forks source link

Figure out many to many mapping between User and BridgeDate #1

Closed boyenn closed 8 years ago

boyenn commented 8 years ago

org.springframework.orm.jpa.JpaObjectRetrievalFailureException: Unable to find be.boyenvaesen.hbctwilio.models.BridgeUserAssociation with id BridgeUserAssociationId{userid=1, bridgedateid=1}; nested exception is javax.persistence.EntityNotFoundException: Unable to find be.boyenvaesen.hbctwilio.models.BridgeUserAssociation with id BridgeUserAssociationId{userid=1, bridgedateid=1}

boyenn commented 8 years ago

Fixed, but code to create an association is now :

User user = new User("boyenvaesen@hotmail.com", "+32468252393", "boyen", "vaesen");
        BridgeDate bridgeDate = new BridgeDate(LocalDate.now());
        bridgeDateRepository.save(bridgeDate);
        userRepository.save(user);

        BridgeUserAssociation bridgeUserAssociation = new BridgeUserAssociation();
        bridgeUserAssociation.setUser(user);
        bridgeUserAssociation.setUserid(user.getId());
        bridgeUserAssociation.setBridgeDate(bridgeDate);
        bridgeUserAssociation.setBridgedateid(bridgeDate.getId());
        bridgeUserAssociation.setComing(true);
        bridgeUserAssociationRepository.save(bridgeUserAssociation);

clean this up and try to find a way to get rid of bridgeUserAssociationRepository alltogether