I have a native query that uses a @SqlResultSetMapping to map to an object. Here is a snippet of the class w/ the mapping:
Code:
@SqlResultSetMapping(name = "logResultSetMapping",
entities = @EntityResult(
entityClass = ClientInstanceLog.class,
fields = {
@FieldResult(name = "clientInstanceLogId", column = "clientinstancelogid"),
@FieldResult(name = "clientInstance.clientInstanceId", column = "clientinstanceid"),
@FieldResult(name = "actionsObtainedDate", column = "actionsobtaineddate"),
@FieldResult(name = "ipAddress", column = "ipaddress")
})
)
public class ClientInstanceLog implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ClientInstanceLogId", unique = true, nullable = false)
private long clientInstanceLogId;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "ClientInstanceId", nullable = false)
private ClientInstance clientInstance;
...
And here is a snippet of that ManyToOne class:
Code:
public class ClientInstance implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ClientInstanceId", unique = true, nullable = false)
private long clientInstanceId;
...
2.3.2 of the Hibernate Annotations manual has an example using dotted notation that does this. However (regardless of whether I place referencedColumnName in the @JoinColumn annotation), I get the following error on startup (some hibernate debug logs included):
Code:
...some debug info...
14:34:23,597 DEBUG org.hibernate.cfg.CollectionSecondPass - Mapped collection key: ClientInstanceId, one-to-many: com.yieldstar.rms.bridge.model.ClientInstanceLog
14:34:23,597 DEBUG org.hibernate.cfg.Configuration - processing native query and ResultSetMapping mappings
14:34:23,597 INFO org.hibernate.cfg.annotations.ResultsetMappingSecondPass - Binding resultset mapping: logResultSetMapping
...error...
Caused by: org.hibernate.MappingException: dotted notation reference neither a component nor a many/one to one
at org.hibernate.cfg.annotations.ResultsetMappingSecondPass.getSubPropertyIterator(ResultsetMappingSecondPass.java:210)
at org.hibernate.cfg.annotations.ResultsetMappingSecondPass.doSecondPass(ResultsetMappingSecondPass.java:86)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1145)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:324)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1121)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:673)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1368)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1334)
... 52 more
Caused by: java.lang.ClassCastException: org.hibernate.mapping.SimpleValue cannot be cast to org.hibernate.mapping.Component
at org.hibernate.cfg.annotations.ResultsetMappingSecondPass.getSubPropertyIterator(ResultsetMappingSecondPass.java:202)
... 60 more
Granted, I am using Spring. Am I doing something wrong here? Is this a Spring specific issue?
Thanks in advance.