mmerder wrote:
No it's not possible.
Mapping another entity would be the right solution. I don't understand why you say that you would load tons of data
well, what i did was this:
Code:
@Entity
public class News implements Serializable{
@Entity
public static class NewsIndex {
@Id int id; String query;
// some col mappings...
}
@OneToOne(fetch = FetchType.LAZY)
@PrimaryKeyJoinColumn(name = "id", referencedColumnName = "id")
private NewsIndex fullTextIndex = null;
// main entity mappings...
when i now query this:
Code:
SELECT o FROM News o JOIN o.fullTextIndex txt WHERE txt.query='foo'
then hibernate does the proper join query, but afterwards loads the index entities as well:
Code:
Hibernate: select news0_.id as id2_, news0_.version as version2_, news0_.lastModified as lastModi3_2_, news0_.author_id as author8_2_, news0_.created as created2_, news0_.deleted as deleted2_, news0_.headline as headline2_, news0_.plainText as plainText2_ from News news0_ inner join idxNews news_newsi1_ on news0_.id=news_newsi1_.id where news_newsi1_.query='dortmund'
[...]
Hibernate: select news_newsi0_.id as id3_0_, news_newsi0_.group_id as group2_3_0_, news_newsi0_.query as query3_0_, news_newsi0_.weight as weight3_0_ from idxNews news_newsi0_ where news_newsi0_.id=?
Hibernate: select news_newsi0_.id as id3_0_, news_newsi0_.group_id as group2_3_0_, news_newsi0_.query as query3_0_, news_newsi0_.weight as weight3_0_ from idxNews news_newsi0_ where news_newsi0_.id=?
Hibernate: select news_newsi0_.id as id3_0_, news_newsi0_.group_id as group2_3_0_, news_newsi0_.query as query3_0_, news_newsi0_.weight as weight3_0_ from idxNews news_newsi0_ where news_newsi0_.id=?
So how could i prevent that? I did not FETCH join, and the association is defined as LAZY.
thx uwe