I created a new roo project and performed the following commands
Then I changed the relationship of ManyToOne to OneToOneCode:persistence setup --provider HIBERNATE --database POSTGRES --databaseName db --userName user --password pass entity --class ~.domain.Person --testAutomatically field string --fieldName firstName --notNull field string --fieldName lastName --notNull field date --fieldName birthDate --notNull --type java.util.Date entity --class ~.domain.Profile --testAutomatically field string --fieldName username --notNull field string --fieldName password --notNull field reference --fieldName person --notNull --type ~.domain.Person
and run 'perform test' which throws :Code:@NotNull @OneToOne(targetEntity = Person.class) @JoinColumn private Person person;
The error message is correct. The question is why the test crashes if it knows about the integrity constraint? shouldn't the test just give back a notification of a passed integrity test?Code:Caused by: org.postgresql.util.PSQLException: ERROR: update o delete en «person» viola la llave foránea «fked8e89a96dc6e8df» en la tabla «profile» Detail: La llave (id)=(5) todavía es referida desde la tabla «profile». at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2062) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1795) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:479) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:367) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:321) at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105) at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2694) ... 52 more Tests run: 9, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.21 sec <<< FAILURE!
Thanks


Reply With Quote