Hi all,
I'm experiencing a strange issue with a native query and was wondering whether anybody could help. What I have is the following code to get a random Tar object:
Code:
Query query = entityManager.createNativeQuery("SELECT * FROM IW.IW_FUND_TAR WHERE ROWNUM = 1", Tar.class);
The Tar class is defined as:
Code:
@Entity
@Table(name = "IW_FUND_TAR")
public class Tar {
...
@OneToOne(fetch=FetchType.EAGER)
@JoinColumn(name="locale", referencedColumnName="locale")
private Locale locale;
...
}
And Locale is simply
Code:
@Entity
@Table(name = "TAR_LOCALE")
public class Locale {
@Id
private Long id;
@Column
private String locale;
}
The IW_FUND_TAR table has a string column called locale that is equal to the locale column on the TAR_LOCALE table. The problem when I try to execute the native query I get a ClassCaseException: Locale. I think Hibernate sees the Locale string in the query and then gets confused as it's expecting an object. Any ideas how to get round this?
Thanks
Nick