@SqlResultSetMapping with @Embedded
I have a problem displaying inline fields in Hibernate. This is the code:
@Entity
@Table(name="CAR")
@SqlResultSetMapping(name = "carMapping",
entities = {
@EntityResult(entityClass = Car.class,
fields = {
@FieldResult(name = "id", column = "ID"),
@FieldResult(name = "producer", column = "PRODUCER"),
@FieldResult(name = "model", column = "MODEL"),
@FieldResult(name="bookNumber",column="SERVICE_BOOK_NUMBER"),
@FieldResult(name="owner", column="SERVICE_BOOK_OWNER")
}
)})
public class Car {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="ID")
private Long id;
@Column(name="PRODUCER")
private String producer;
@Column(name="MODEL")
private String model;
@Embedded
@AttributeOverrides({
@AttributeOverride(name="bookNumber", column=@Column(name="SERVICE_BOOK_NUMBER")),
@AttributeOverride(name="owner", column=@Column(name="SERVICE_BOOK_OWNER")),
})
private ServiceBook serviceBook;
When I try to eject the car, I get the following error:
javax.ejb.EJBTransactionRolledbackException: The transaction has been marked rollback only
because the bean encountered a non-application exception :javax.persistence.PersistenceException :
org.hibernate.exception.SQLGrammarException: Column 'SERVICE4_0_0_' not found
My question is, is it possible to use @SqlResultSetMapping
and @Embedded
?
+3
source to share