-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Problem with @Transient fields while indexing using Lucene.
PostPosted: Tue Sep 22, 2009 1:50 am 
Newbie

Joined: Tue Sep 22, 2009 1:25 am
Posts: 2
Hi

I have problem with fields marked as @Transient.

Please see the code below.
In Candidate Class..

Code:
@IndexedEmbedded
@Transient
@OneToMany(fetch= FetchType.LAZY )
@JoinTable(name="events", joinColumns = {@JoinColumn(name = "candidate_id")}, inverseJoinColumns = {@JoinColumn(name = "comment_id")})
    public List<Comments> getComments() {
        return comments;}
       
... //setter for the comments.


Comments.java........

Code:
@Entity
@Table(name = "comments")
@Indexed
public class Comments
{

   private String   commentId;
   private String   eventId;
   private String   comments;
   private Date   date;

   @Id
   @GeneratedValue(strategy = GenerationType.IDENTITY)
   @DocumentId
   @Column(name = "comment_id")
   public String getCommentId()
   {
      return commentId;
   }

      
   @Column(name = "event_id")
   public String getEventId()
   {
      return eventId;
   }
      
   @Basic
   @Column(name = "comments")
   @Field(index = Index.TOKENIZED, store = Store.YES)
   public String getComments()
   {
      return comments;
   }

//setters...   
   
}



If I DO NOT mark Comments as @Transient in Candidate.java, it saves 'comments' in DB properly, and gets indexed properly. but INSERTS few null columns in 'events' table.

------
If I mark Comments as @Transient, it inserts 'comments' as well as 'events' into DB properly but fails to index 'comments' in candidate index.


Could anybody please help me in solving this problem, I want 'comments' to be indexed and searched. as well as events table should get populated with correct data.

Thanks for looking!


Top
 Profile  
 
 Post subject: Re: Problem with @Transient fields while indexing using Lucene.
PostPosted: Tue Sep 22, 2009 10:09 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
but INSERTS few null columns in 'events' table.

what's "events table"? some parent entity?

Quote:
If I mark Comments as @Transient, it inserts 'comments' as well as 'events' into DB properly but fails to index 'comments' in candidate index.

You don't mean the other way around?

what's this "public String getEventId()" ? can't you map the objects properly referring to instances instead of to their keys?

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject: Re: Problem with @Transient fields while indexing using Lucene.
PostPosted: Tue Sep 22, 2009 11:46 am 
Newbie

Joined: Tue Sep 22, 2009 1:25 am
Posts: 2
Quote:
what's "events table"? some parent entity?

yes it is.

Quote:
You don't mean the other way around?
what's this "public String getEventId()" ? can't you map the objects properly referring to instances instead of to their keys?


I am sorry, I couldnt get what you mean.

--


Top
 Profile  
 
 Post subject: Re: Problem with @Transient fields while indexing using Lucene.
PostPosted: Tue Sep 22, 2009 12:31 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
Quote:
what's "events table"? some parent entity?

yes it is.

Could you show that or explain the relation with the other entities?

Quote:
I am sorry, I couldnt get what you mean.

I mean why
Code:
public String getEventId()

and not just
Code:
public Event getEvent()
?
It appears you are wiring entities by yourself instead of delegating Hibernate to this tasks; this way it's not possible to automagically detect relations.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.