self-manytoone

Ich habe eine Personen klasse, wobei created_by und updated_by ein self manytoone ist:

Code:
@Entity(name="persons")
@Table(indexes = { @Index(name = "IDX_EMAIL_PASSWORD", columnList = "email, password") })
public class Person {
        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        private Long id;
    
        @CreationTimestamp
        private LocalDateTime    created_at;
    
        @ManyToOne(cascade = CascadeType.REMOVE, fetch = FetchType.LAZY)
        @JoinColumn(name = "created_by")
        private Person    created_by;
/*       
        @OneToMany(fetch = FetchType.LAZY, mappedBy = "createdBy")
        @JoinColumn(name = "created_by")
        private List<Person> created;
*/       
        @Null
        @UpdateTimestamp
        private LocalDateTime    updated_at;
        
        @ManyToOne(cascade = CascadeType.REMOVE, fetch = FetchType.LAZY)
        @JoinColumn(name = "updated_by")
        private Person    updated_by;
/*       
        @OneToMany(fetch = FetchType.LAZY, mappedBy = "updatedBy")
        @JoinColumn(name = "updated_by")
        private List<Person> updated;
*/       
        @javax.validation.constraints.Pattern(regexp = "(?=.*\\S.*.*).{3,255}")
        private String firstname;   
            
        @javax.validation.constraints.Pattern(regexp = "(?=.*\\S.*.*).{3,255}")
        private String lastname;   
            
        @Column(unique=true)
        @Email(message = "Email should be valid")
        private String email;   
            
        @javax.validation.constraints.Pattern(regexp = "(?=.*\\S.*.*).{6,255}")
        private String password;   
        
        public Person() {
        }
        
        public Person(Person person) {
            super();

            this.firstname = person.firstname;
            this.lastname = person.lastname;
            this.email = person.email;
            this.password = person.password;
        }
        
        public Person(@Pattern(regexp = "(?=.*\\S.*.*).{3,255}") String firstname,
                @Pattern(regexp = "(?=.*\\S.*.*).{3,255}") String lastname,
                @Email(message = "Email should be valid") String email,
                @Pattern(regexp = "(?=.*\\S.*.*).{6,255}") String password) {
            super();
            this.firstname = firstname;
            this.lastname = lastname;
            this.email = email;
            this.password = password;
        }


        public Long getId() {
            return id;
        }

        public void setId(Long id) {
            this.id = id;
        }

        public LocalDateTime getCreatedAt() {
            return created_at;
        }

        public void setCreatedAt(LocalDateTime created_at) {
            this.created_at = created_at;
        }

        public Person getCreatedBy() {
            return created_by;
        }

        public void setCreatedBy(Person created_by) {
            this.created_by = created_by;
        }

        public LocalDateTime getUpdatedAt() {
            return updated_at;
        }

        public void setUpdatedAt(LocalDateTime updated_at) {
            this.updated_at = updated_at;
        }

        public Person getUpdatedBy() {
            return updated_by;
        }

        public void setUpdatedBy(Person updated_by) {
            this.updated_by = updated_by;
        }

        public String getFirstname() {
            return firstname;
        }

        public void setFirstname(String firstname) {
            this.firstname = firstname;
        }

        public String getLastname() {
            return lastname;
        }

        public void setLastname(String lastname) {
            this.lastname = lastname;
        }

        public String getEmail() {
            return email;
        }

        public void setEmail(String email) {
            this.email = email;
        }

        public String getPassword() {
            return password;
        }

        public void setPassword(String password) {
            this.password = password;
        }
    
        @Override
        public int hashCode() {
            final int prime = 31;
            int result = 1;
            
            result = prime * result + ((email == null) ? 0 : email.hashCode());
            result = prime * result + ((id == null) ? 0 : id.hashCode());
            
            return result;
        }
        
        @Override
        public boolean equals(Object obj) {
            if (this == obj)
                return true;
            
            if (obj == null)
                return false;
            
            if (getClass() != obj.getClass())
                return false;
            
            Person other = (Person) obj;
            
            if (email == null) {
                if (other.email != null)
                    return false;
            } else if (!email.equals(other.email))
                return false;
            
            if (id == null) {
                if (other.id != null)
                    return false;
            } else if (!id.equals(other.id))
                return false;
            
            return true;
        }

        public Person clone() {
            return new Person(this);
        }
        
        @Override
        public String toString() {
            return "Person [id=" + id + ", created_at=" + created_at + ", created_by=" + created_by + ", updated_at="
                    + updated_at + ", updated_by=" + updated_by + ", firstname=" + firstname + ", lastname=" + lastname
                    + ", email=" + email + ", password=" + password + "]";
        }
}
Hierbei können "Parent Persons" beliebig viele "Child Persons" erstellen. Wird jetzt "Parent Person" gelöscht, dann sollen alle von dieser Instanz erstellten "Child Persons" auf null gesetzt werden.

Hierzu habe ich eine Test Klasse geschrieben:
Code:
        @Test
        public void testDeleteChildPersonForCreatedBy() {
            // initialize
            String firstnameValue1 = "firstname1";
            String lastnameValue1 = "lastname1";
            String emailValue1 = "[email protected]";
            String passwordValue1 = "password1";           
            
            Person parentPerson = new Person();
            parentPerson.setFirstname(firstnameValue1);
            parentPerson.setLastname(lastnameValue1);
            parentPerson.setEmail(emailValue1);
            parentPerson.setPassword(passwordValue1);
            
            personRepository.save(parentPerson);
            assertTrue(parentPerson.getId() > 0);
            
            String firstnameValue2 = "firstname2";
            String lastnameValue2 = "lastname2";
            String emailValue2 = "[email protected]";
            String passwordValue2 = "password2";           
            
            Person childPerson = new Person();
            childPerson.setCreatedBy(parentPerson);
            childPerson.setFirstname(firstnameValue2);
            childPerson.setLastname(lastnameValue2);
            childPerson.setEmail(emailValue2);
            childPerson.setPassword(passwordValue2);

            personRepository.save(childPerson);
            assertTrue(childPerson.getId() > 0);
            
            // test
            personRepository.delete(childPerson);
            
            long counts = personRepository.count();
            assertEquals(1L, counts);
            
            // clean up
            personRepository.delete(parentPerson);
        }
Aber irgendwie bekomme ich es nicht hin. Die Test-Funktion stößt immer wieder auf eine AsserationError.
Wie müsste die Entity "Person" korrekt aussehen?
Hierbei möchte ich das, wenn die Parent Person
 
Da fehlt ein Teil des Satzes?
Da hast du recht. War noch ein Überbleibsel von
Hierbei können "Parent Persons" beliebig viele "Child Persons" erstellen. Wird jetzt "Parent Person" gelöscht, dann sollen alle von dieser Instanz erstellten "Child Persons" auf null gesetzt werden.
Ich meine damit dann soll created_by vom "Child Person" auf Null gesetzt werden.

Deshalb bitte den letzten Satz ignorieren.
 
counts ist zwei?
Hast du an den Anfang des Tests mal eine Assumption gesetzt und sichergestellt, dass dort 0 vorhanden sind?
 
counts ist zwei?
Hast du an den Anfang des Tests mal eine Assumption gesetzt und sichergestellt, dass dort 0 vorhanden sind?
Wieso zwei????? Durch
Code:
// test
            personRepository.delete(childPerson);
wird doch childPerson gelöscht. Also sollte doch
Code:
assertEquals(1L, counts);
korrekt sein. Sprich nur noch 1 Datensatz vorhanden sein.
 
Wieso zwei????? Durch
Code:
// test
            personRepository.delete(childPerson);
wird doch childPerson gelöscht
Das war eine Frage von mir, keine Antwort.

Du sagtest, dass die Assertion fehl schlägt, also ist es schon mal nicht 1. Wenn man alles völlig unwahrscheinliche weg lässt, bleiben 0 und 2 übrig - da war 2 kein so unabwegiger Verdacht...
Aber anstatt mich raten zu lassen (und dich dann über meinen Tipp zu beschweren), könntest du auch einfach sagen, was genau der Fehler ist ;)
 
Ich habe die Test - Funktion nochmal abgeändert:
Code:
        @Test
        public void testDeleteChildPersonForCreatedBy() {
            // initialize
            String firstnameValue1 = "firstname1";
            String lastnameValue1 = "lastname1";
            String emailValue1 = "[email protected]";
            String passwordValue1 = "password1";           
            
            Person parentPerson = new Person();
            parentPerson.setFirstname(firstnameValue1);
            parentPerson.setLastname(lastnameValue1);
            parentPerson.setEmail(emailValue1);
            parentPerson.setPassword(passwordValue1);
            
            personRepository.save(parentPerson);
            assertTrue(parentPerson.getId() > 0);
            
            String firstnameValue2 = "firstname2";
            String lastnameValue2 = "lastname2";
            String emailValue2 = "[email protected]";
            String passwordValue2 = "password2";           
            
            Person childPerson = new Person();
            childPerson.setCreatedBy(parentPerson);
            childPerson.setFirstname(firstnameValue2);
            childPerson.setLastname(lastnameValue2);
            childPerson.setEmail(emailValue2);
            childPerson.setPassword(passwordValue2);

            assertTrue(childPerson.getId() > 0);
            
            long counts = personRepository.count();
            assertEquals(2L, counts);
            
            // test
            personRepository.delete(childPerson);
            
            counts = personRepository.count();
            assertEquals(1L, counts);
            
            // clean up
            personRepository.delete(parentPerson);
        }
sprich den Teil
Code:
            long counts = personRepository.count();
            assertEquals(2L, counts);
hinzugefügt. Diese Assert ist ok. Die Test - Funktion mosert immer noch den obigen, besagten Teil an.
 
Das war eine Frage von mir, keine Antwort.

Du sagtest, dass die Assertion fehl schlägt, also ist es schon mal nicht 1. Wenn man alles völlig unwahrscheinliche weg lässt, bleiben 0 und 2 übrig - da war 2 kein so unabwegiger Verdacht...
Aber anstatt mich raten zu lassen (und dich dann über meinen Tipp zu beschweren), könntest du auch einfach sagen, was genau der Fehler ist ;)
Du warst etwas schneller, war gerad noch am abändern ;)
 
Also liegt es an der Cascade? Wie müsste ich es denn dann schreiben, um zu erreichen, dass, wie oben beschrieben, wenn die "Parent Person" gelöscht wird, alle Eigenschaften createdBy der "Child Person" auf null gesetzt wird, die von "Parent Person" beinhalten, wenn "Parent Person" gelöscht wird?
 
Also liegt es an der Cascade?
Sollte. Du hast eine Referenz auf eine andere Person. Zu dieser Referenz hast Du angegeben, dass ein Remove einer Entity kaskadierend weitergegeben werden soll. D. h. löscht Du eine Person, löschst Du automatisch die referenzierte Person mit (sofern das überhaupt möglich ist, denn es könnte ja andere Personen geben, die diese Person ebenfalls referenzieren).

Wie müsste ich es denn dann schreiben, um zu erreichen, dass, wie oben beschrieben, wenn die "Parent Person" gelöscht wird, alle Eigenschaften createdBy der "Child Person" auf null gesetzt wird, die von "Parent Person" beinhalten, wenn "Parent Person" gelöscht wird?
Ich denke, Du musst die Beziehungen vor dem Entfernen des Parents "manuell" entfernen. D. h. Du fügst in der delete-Methode des Repositories vorher ein DELETE FROM ... (EDIT: Käse, ein UPDATE natürlich) ein.
 
Hab doch noch ein Problem:

Code:
@Entity
@Table(name="persons", indexes = { @Index(name = "IDX_EMAIL_PASSWORD", columnList = "email, password") })
public class Person {
        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        private Long id;
    
        @CreationTimestamp
        private LocalDateTime    created_at;
    
        @ManyToOne(fetch = FetchType.LAZY)
        @JoinColumn(name = "created_by")
        private Person    created_by;
/*       
        @OneToMany(fetch = FetchType.LAZY, mappedBy = "createdBy")
        @JoinColumn(name = "created_by")
        private List<Person> created;
*/       
        @Null
        @UpdateTimestamp
        private LocalDateTime    updated_at;
        
        @ManyToOne(fetch = FetchType.LAZY)
        @JoinColumn(name = "updated_by")
        private Person    updated_by;
/*       
        @OneToMany(fetch = FetchType.LAZY, mappedBy = "updatedBy")
        @JoinColumn(name = "updated_by")
        private List<Person> updated;
*/       
        @javax.validation.constraints.Pattern(regexp = "(?=.*\\S.*.*).{3,255}")
        private String firstname;   
            
        @javax.validation.constraints.Pattern(regexp = "(?=.*\\S.*.*).{3,255}")
        private String lastname;   
            
        @Column(unique=true)
        @Email(message = "Email should be valid")
        private String email;   
            
        @javax.validation.constraints.Pattern(regexp = "(?=.*\\S.*.*).{6,255}")
        private String password;   
        
        public Person() {
        }
        
        public Person(Person person) {
            super();

            this.firstname = person.firstname;
            this.lastname = person.lastname;
            this.email = person.email;
            this.password = person.password;
        }
        
        public Person(@Pattern(regexp = "(?=.*\\S.*.*).{3,255}") String firstname,
                @Pattern(regexp = "(?=.*\\S.*.*).{3,255}") String lastname,
                @Email(message = "Email should be valid") String email,
                @Pattern(regexp = "(?=.*\\S.*.*).{6,255}") String password) {
            super();
            this.firstname = firstname;
            this.lastname = lastname;
            this.email = email;
            this.password = password;
        }


        public Long getId() {
            return id;
        }

        public void setId(Long id) {
            this.id = id;
        }

        public LocalDateTime getCreatedAt() {
            return created_at;
        }

        public void setCreatedAt(LocalDateTime created_at) {
            this.created_at = created_at;
        }

        public Person getCreatedBy() {
            return created_by;
        }

        public void setCreatedBy(Person created_by) {
            this.created_by = created_by;
        }

        public LocalDateTime getUpdatedAt() {
            return updated_at;
        }

        public void setUpdatedAt(LocalDateTime updated_at) {
            this.updated_at = updated_at;
        }

        public Person getUpdatedBy() {
            return updated_by;
        }

        public void setUpdatedBy(Person updated_by) {
            this.updated_by = updated_by;
        }

        public String getFirstname() {
            return firstname;
        }

        public void setFirstname(String firstname) {
            this.firstname = firstname;
        }

        public String getLastname() {
            return lastname;
        }

        public void setLastname(String lastname) {
            this.lastname = lastname;
        }

        public String getEmail() {
            return email;
        }

        public void setEmail(String email) {
            this.email = email;
        }

        public String getPassword() {
            return password;
        }

        public void setPassword(String password) {
            this.password = password;
        }
    
        @Override
        public int hashCode() {
            final int prime = 31;
            int result = 1;
            
            result = prime * result + ((email == null) ? 0 : email.hashCode());
            result = prime * result + ((id == null) ? 0 : id.hashCode());
            
            return result;
        }
        
        @Override
        public boolean equals(Object obj) {
            if (this == obj)
                return true;
            
            if (obj == null)
                return false;
            
            if (getClass() != obj.getClass())
                return false;
            
            Person other = (Person) obj;
            
            if (email == null) {
                if (other.email != null)
                    return false;
            } else if (!email.equals(other.email))
                return false;
            
            if (id == null) {
                if (other.id != null)
                    return false;
            } else if (!id.equals(other.id))
                return false;
            
            return true;
        }

        public Person clone() {
            return new Person(this);
        }
        
        @Override
        public String toString() {
            return "Person [id=" + id + ", created_at=" + created_at + ", created_by=" + created_by + ", updated_at="
                    + updated_at + ", updated_by=" + updated_by + ", firstname=" + firstname + ", lastname=" + lastname
                    + ", email=" + email + ", password=" + password + "]";
        }
mit der Repository
Code:
public interface PersonRepository extends CrudRepository<Person, Long> {

        Person findByEmail(String email);
        
        @Modifying
        @Query("update from Person p SET p.created_by = null where p.created_by = ?1")
        void setCreatedByToNull(Long id);
        
        @Modifying
        @Query("update from Person p SET p.updated_by = null where p.updated_by = ?1")
        void setUpdatedByToNull(Long id);
        
}
und der Test Funktion
Code:
        @Test
        public void testSetCreatedByToNull() {
            long countPersons = personRepository.count();
            assertEquals(0, countPersons);
            
            // initialize
            String firstnameValue1 = "firstname1";
            String lastnameValue1 = "lastname1";
            String emailValue1 = "[email protected]";
            String passwordValue1 = "password1";           
            
            Person parentPerson = new Person();
            parentPerson.setFirstname(firstnameValue1);
            parentPerson.setLastname(lastnameValue1);
            parentPerson.setEmail(emailValue1);
            parentPerson.setPassword(passwordValue1);
            
            personRepository.save(parentPerson);
            assertTrue(parentPerson.getId() > 0);

            Optional<Person> foundParentPerson = personRepository.findById(parentPerson.getId());
            assertTrue(foundParentPerson.isPresent());
            assertEquals(foundParentPerson.get().getId(), parentPerson.getId());
            
            String firstnameValue2 = "firstname2";
            String lastnameValue2 = "lastname2";
            String emailValue2 = "[email protected]";
            String passwordValue2 = "password2";           
            
            Person childPerson1 = new Person();
            childPerson1.setCreatedBy(parentPerson);
            childPerson1.setFirstname(firstnameValue2);
            childPerson1.setLastname(lastnameValue2);
            childPerson1.setEmail(emailValue2);
            childPerson1.setPassword(passwordValue2);

            personRepository.save(childPerson1);
            assertTrue(childPerson1.getId() > 0);
            
            Optional<Person> foundChildPerson1 = personRepository.findById(childPerson1.getId());
            assertTrue(foundChildPerson1.isPresent());
            assertEquals(foundChildPerson1.get().getId(), childPerson1.getId());

            String firstnameValue3 = "firstname2";
            String lastnameValue3 = "lastname2";
            String emailValue3 = "[email protected]";
            String passwordValue3 = "password2";           
            
            Person childPerson2 = new Person();
            childPerson2.setCreatedBy(parentPerson);
            childPerson2.setFirstname(firstnameValue3);
            childPerson2.setLastname(lastnameValue3);
            childPerson2.setEmail(emailValue3);
            childPerson2.setPassword(passwordValue3);

            personRepository.save(childPerson2);
            assertTrue(childPerson2.getId() > 0);
            
            Optional<Person> foundChildPerson2 = personRepository.findById(childPerson2.getId());
            assertTrue(foundChildPerson2.isPresent());
            assertEquals(foundChildPerson2.get().getId(), childPerson2.getId());
            
            long counts = personRepository.count();
            assertEquals(3L, counts);
            
            // test
            personRepository.setCreatedByToNull(parentPerson.getId());
            
            counts = personRepository.count();
            assertEquals(3L, counts);
            
            Optional<Person> foundChildPerson1Try2 = personRepository.findById(childPerson1.getId());
            assertFalse(foundChildPerson1Try2.isPresent());
            assertNull(foundChildPerson1Try2.get().getCreatedBy());
            
            Optional<Person> foundChildPerson2Try2 = personRepository.findById(childPerson2.getId());
            assertFalse(foundChildPerson2Try2.isPresent());
            assertNull(foundChildPerson1Try2.get().getCreatedBy());
            
            // clean up
            personRepository.delete(foundParentPerson.get());
            personRepository.delete(foundChildPerson1.get());
            personRepository.delete(foundChildPerson2.get());
        }
führt beim Testen der Funktion zu der Meldung
org.springframework.dao.InvalidDataAccessApiUsageException: Parameter value [1] did not match expected type [com.project.entities.Person (n/a)]; nested exception is java.lang.IllegalArgumentException: Parameter value [1] did not match expected type [com.project.entities.Person (n/a)]
at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:373)
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:255)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:527)
at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:61)
at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:242)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:153)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:138)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.data.repository.core.support.SurroundingTransactionDetectorMethodInterceptor.invoke(SurroundingTransactionDetectorMethodInterceptor.java:61)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
at com.sun.proxy.$Proxy132.setCreatedByToNull(Unknown Source)
at com.project.repositories.PersonRepositoryTest.testSetCreatedByToNull(PersonRepositoryTest.java:435)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:74)
at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
Caused by: java.lang.IllegalArgumentException: Parameter value [4] did not match expected type [com.project.entities.Person (n/a)]
at org.hibernate.query.spi.QueryParameterBindingValidator.validate(QueryParameterBindingValidator.java:54)
at org.hibernate.query.spi.QueryParameterBindingValidator.validate(QueryParameterBindingValidator.java:27)
at org.hibernate.query.internal.QueryParameterBindingImpl.validate(QueryParameterBindingImpl.java:90)
at org.hibernate.query.internal.QueryParameterBindingImpl.setBindValue(QueryParameterBindingImpl.java:55)
at org.hibernate.query.internal.AbstractProducedQuery.setParameter(AbstractProducedQuery.java:515)
at org.hibernate.query.internal.AbstractProducedQuery.setParameter(AbstractProducedQuery.java:110)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.orm.jpa.SharedEntityManagerCreator$DeferredQueryInvocationHandler.invoke(SharedEntityManagerCreator.java:402)
at com.sun.proxy.$Proxy138.setParameter(Unknown Source)
at org.springframework.data.jpa.repository.query.QueryParameterSetter$NamedOrIndexedQueryParameterSetter.lambda$setParameter$5(QueryParameterSetter.java:124)
at org.springframework.data.jpa.repository.query.QueryParameterSetter$ErrorHandling$1.execute(QueryParameterSetter.java:175)
at org.springframework.data.jpa.repository.query.QueryParameterSetter$NamedOrIndexedQueryParameterSetter.setParameter(QueryParameterSetter.java:124)
at org.springframework.data.jpa.repository.query.ParameterBinder.lambda$bind$0(ParameterBinder.java:79)
at java.util.ArrayList.forEach(Unknown Source)
at java.util.Collections$UnmodifiableCollection.forEach(Unknown Source)
at org.springframework.data.jpa.repository.query.ParameterBinder.bind(ParameterBinder.java:79)
at org.springframework.data.jpa.repository.query.ParameterBinder.bind(ParameterBinder.java:74)
at org.springframework.data.jpa.repository.query.ParameterBinder.bindAndPrepare(ParameterBinder.java:96)
at org.springframework.data.jpa.repository.query.AbstractStringBasedJpaQuery.doCreateQuery(AbstractStringBasedJpaQuery.java:92)
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.createQuery(AbstractJpaQuery.java:210)
at org.springframework.data.jpa.repository.query.JpaQueryExecution$ModifyingExecution.doExecute(JpaQueryExecution.java:256)
at org.springframework.data.jpa.repository.query.JpaQueryExecution.execute(JpaQueryExecution.java:91)
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.doExecute(AbstractJpaQuery.java:136)
at org.springframework.data.jpa.repository.query.AbstractJpaQuery.execute(AbstractJpaQuery.java:125)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:605)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$invoke$3(RepositoryFactorySupport.java:595)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:595)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:59)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:294)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:139)
... 42 more
Wobei ich jetzt nicht so ganz verstehe was hier schief läuft.
 
Passende Stellenanzeigen aus deiner Region:

Neue Themen

Oben