views:

33

answers:

3

Hey hey :-)

ps: I'm novice with hibernate search

This is the morning question. I got one application running with gwt+hibernate. I need to add hibernate search in the application.

I took care of this application but all the system was already in place and running.

I can see on the entity level, that no @id annotation is used to define the pk of the entity. I would like to know if this is something used for hibernate-search.

Because I just added @indexed to one entity. I can always run the app but there there is an issue when i try to update the entity using the application. (there is a rollback during the transaction that save the entity).

Is it possible that's only because missing annotations.

Thanks in advance :-)

A: 

Here is the exact piece of code that is failling.

My entity "person" extends versions. and the code failed on the session.flush().

private Version update(Session session, VersionedObject storedObject, String userId, String message) { Version version = new Version(userId, message);

    session.save(version);
    session.flush();

    return version;
}

Just to answer your next question, yes there is a transaction declared on the method calling this method :-)

AbstractMan
A: 

In fact, what I don't understand is how and why, just putting @Indexed on an entity can affect the update of this entity and come to a rollback.

AbstractMan
A: 

I've also tested with another entity. I just added @indexed annotation and i'm not able anymore to save a version in the db. Am I missing somthing?

code:

@Entity
@Table(name="VERSIONS")
@Indexed
public class Version implements Serializable {    
  @Id 
  @GeneratedValue(strategy=GenerationType.AUTO)
  @Column(name="V_NO", length=10)
  private Integer valueNb;

  @Column(nullable=false)
  @Temporal(TemporalType.TIMESTAMP)
  private Date tstamp;

  @Column(length=UserProfile.CAID_LENGTH, nullable=false)
  private String userId;

  @Column(length=500)
  private String message;

  @CollectionOfElements
  @JoinTable(
      name="TAGS",
      joinColumns=@JoinColumn(name="V_NO")
      )
  @Column(name="LABEL", length=64)
  private Set<String> tags;
  ...
  }
AbstractMan