Skip to content
Snippets Groups Projects
Commit 04a4a3f5 authored by ribeaudc's avatar ribeaudc
Browse files

[LMS-591] change: - Switching on Hibernate Search and put a minimal set of annotations.

SVN: 8818
parent 949695d7
No related branches found
No related tags found
No related merge requests found
......@@ -38,7 +38,7 @@
<classpathentry kind="lib" path="/libraries/spring/test/spring-test.jar" sourcepath="/libraries/spring/test/src.jar"/>
<classpathentry kind="lib" path="/libraries/commons-collections/commons-collections.jar" sourcepath="/libraries/commons-collections/src.jar"/>
<classpathentry kind="lib" path="/libraries/junit/junit.jar"/>
<classpathentry kind="lib" path="/libraries/hibernate-search/hibernate-search.jar"/>
<classpathentry kind="lib" path="/libraries/hibernate-search/hibernate-search.jar" sourcepath="/libraries/hibernate-search/src.zip"/>
<classpathentry kind="lib" path="/libraries/hibernate-search/jms.jar"/>
<classpathentry kind="lib" path="/libraries/hibernate-search/lucene-core-2.3.0.jar"/>
<classpathentry kind="lib" path="/libraries/ehcache/ehcache.jar" sourcepath="/libraries/ehcache/src.zip"/>
......
......@@ -267,9 +267,6 @@
<lib dir="${gwt.lib}">
<include name="gwt-servlet.jar" />
</lib>
<lib dir="${lib}/hibernate-search">
<include name="jms.jar" />
</lib>
<!-- Database -->
<lib dir="${lib}/postgresql">
<include name="postgresql.jar" />
......@@ -321,6 +318,10 @@
<include name="*.jar" />
<exclude name="src.jar" />
</lib>
<!-- Hibernate Search -->
<lib dir="${lib}/hibernate-search">
<include name="*.jar" />
</lib>
</war>
<!-- Does some cleaning. -->
<delete file="${jar.file}" failonerror="true" />
......
......@@ -42,6 +42,11 @@ import org.apache.commons.lang.builder.ToStringBuilder;
import org.hibernate.Hibernate;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Store;
import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;
import org.hibernate.validator.Pattern;
......@@ -60,6 +65,7 @@ import ch.systemsx.cisd.openbis.generic.shared.GenericSharedConstants;
@Table(name = TableNames.EXPERIMENTS_TABLE, uniqueConstraints =
{ @UniqueConstraint(columnNames =
{ ColumnNames.CODE_COLUMN, ColumnNames.PROJECT_COLUMN }) })
@Indexed
public class ExperimentPE extends HibernateAbstractRegistrationHolder implements
IEntityPropertiesHolder<ExperimentPropertyPE>, IIdAndCodeHolder, Comparable<ExperimentPE>
{
......@@ -103,6 +109,7 @@ public class ExperimentPE extends HibernateAbstractRegistrationHolder implements
@Id
@SequenceGenerator(name = SequenceNames.EXPERIMENT_SEQUENCE, sequenceName = SequenceNames.EXPERIMENT_SEQUENCE, allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = SequenceNames.EXPERIMENT_SEQUENCE)
@DocumentId
public Long getId()
{
return id;
......@@ -117,6 +124,7 @@ public class ExperimentPE extends HibernateAbstractRegistrationHolder implements
@Length(min = 1, max = 40, message = ValidationMessages.CODE_LENGTH_MESSAGE)
@NotNull(message = ValidationMessages.CODE_NOT_NULL_MESSAGE)
@Pattern(regex = AbstractIdAndCodeHolder.CODE_PATTERN, flags = java.util.regex.Pattern.CASE_INSENSITIVE, message = ValidationMessages.CODE_PATTERN_MESSAGE)
@Field(index = Index.UN_TOKENIZED, store = Store.YES)
public String getCode()
{
return code;
......@@ -218,7 +226,7 @@ public class ExperimentPE extends HibernateAbstractRegistrationHolder implements
property.setEntity(this);
getExperimentProperties().add(property);
}
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "parent")
@Private
public List<AttachmentPE> getExperimentAttachments()
......
......@@ -42,6 +42,11 @@ import org.hibernate.Hibernate;
import org.hibernate.annotations.Check;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Store;
import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;
import org.hibernate.validator.Pattern;
......@@ -62,6 +67,7 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SampleIdentifier;
@Check(constraints = "(" + ColumnNames.DATABASE_INSTANCE_COLUMN + " IS NOT NULL AND "
+ ColumnNames.GROUP_COLUMN + " IS NULL) OR (" + ColumnNames.DATABASE_INSTANCE_COLUMN
+ " IS NULL AND " + ColumnNames.GROUP_COLUMN + " IS NOT NULL)")
@Indexed
public class SamplePE extends HibernateAbstractRegistrationHolder implements IIdAndCodeHolder,
Comparable<SamplePE>, IEntityPropertiesHolder<SamplePropertyPE>
{
......@@ -293,6 +299,7 @@ public class SamplePE extends HibernateAbstractRegistrationHolder implements IId
@SequenceGenerator(name = SequenceNames.SAMPLE_SEQUENCE, sequenceName = SequenceNames.SAMPLE_SEQUENCE, allocationSize = 1)
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = SequenceNames.SAMPLE_SEQUENCE)
@DocumentId
public final Long getId()
{
return id;
......@@ -301,6 +308,7 @@ public class SamplePE extends HibernateAbstractRegistrationHolder implements IId
@NotNull(message = ValidationMessages.CODE_NOT_NULL_MESSAGE)
@Length(min = 1, max = 40, message = ValidationMessages.CODE_LENGTH_MESSAGE)
@Pattern(regex = AbstractIdAndCodeHolder.CODE_PATTERN, flags = java.util.regex.Pattern.CASE_INSENSITIVE, message = ValidationMessages.CODE_PATTERN_MESSAGE)
@Field(index = Index.UN_TOKENIZED, store = Store.YES)
public String getCode()
{
return code;
......
......@@ -6,11 +6,11 @@
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<!--
// Hibernate
-->
<bean id="hibernate-session-factory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
depends-on="sql-script-provider">
......@@ -77,10 +77,11 @@
<prop key="hibernate.cache.provider_class">
org.hibernate.cache.EhCacheProvider
</prop>
<prop key="hibernate.search.default.directory_provider">
org.hibernate.search.store.FSDirectoryProvider
</prop>
<prop key="hibernate.search.default.indexBase">./indexes</prop>
<!--
<prop key="hibernate.search.default.indexBase">./indexes</prop>
<prop key="hibernate.search.default.directory_provider">org.hibernate.search.store.FSDirectoryProvider</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.use_sql_comments">true</prop>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment