[seam-commits] Seam SVN: r13664 - in modules/persistence/trunk/impl: src/main/java/org/jboss/seam/persistence and 3 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Mon Aug 30 04:54:50 EDT 2010


Author: swd847
Date: 2010-08-30 04:54:49 -0400 (Mon, 30 Aug 2010)
New Revision: 13664

Added:
   modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/HibernateSearchTest.java
   modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/IndexedHotel.java
   modules/persistence/trunk/impl/src/test/resources/META-INF/persistence-search.xml
Modified:
   modules/persistence/trunk/impl/pom.xml
   modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/HibernatePersistenceProvider.java
   modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java
   modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java
   modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/SeamPersistenceProvider.java
   modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/ArtifactNames.java
Log:
hibernate search integration


Modified: modules/persistence/trunk/impl/pom.xml
===================================================================
--- modules/persistence/trunk/impl/pom.xml	2010-08-30 07:00:01 UTC (rev 13663)
+++ modules/persistence/trunk/impl/pom.xml	2010-08-30 08:54:49 UTC (rev 13664)
@@ -108,7 +108,12 @@
          <type>jar</type>
          <scope>compile</scope>
       </dependency>
-
+		<dependency>
+		     <groupId>org.hibernate</groupId>
+		     <artifactId>hibernate-search</artifactId>
+		     <version>3.2.1.Final</version>
+		     <optional>true</optional>
+		 </dependency>
       <dependency>
          <groupId>org.jboss.arquillian</groupId>
          <artifactId>arquillian-junit</artifactId>

Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/HibernatePersistenceProvider.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/HibernatePersistenceProvider.java	2010-08-30 07:00:01 UTC (rev 13663)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/HibernatePersistenceProvider.java	2010-08-30 08:54:49 UTC (rev 13664)
@@ -1,7 +1,8 @@
 package org.jboss.seam.persistence;
 
-import java.lang.reflect.Field;
 import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.Set;
 
 import javax.enterprise.inject.Instance;
 import javax.inject.Inject;
@@ -13,7 +14,7 @@
 import org.hibernate.TransientObjectException;
 import org.hibernate.proxy.HibernateProxy;
 import org.jboss.seam.persistence.transaction.FlushModeType;
-import org.jboss.weld.extensions.core.Veto;
+import org.jboss.weld.extensions.util.Reflections;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -26,7 +27,6 @@
  * @author Stuart Douglas
  * 
  */
- at Veto
 public class HibernatePersistenceProvider extends SeamPersistenceProvider
 {
 
@@ -34,10 +34,9 @@
    Instance<PersistenceContextsImpl> persistenceContexts;
 
    private static Logger log = LoggerFactory.getLogger(HibernatePersistenceProvider.class);
-   private static Class<?> FULL_TEXT_SESSION_PROXY_CLASS;
    private static Method FULL_TEXT_SESSION_CONSTRUCTOR;
-   private static Class<?> FULL_TEXT_ENTITYMANAGER_PROXY_CLASS;
    private static Method FULL_TEXT_ENTITYMANAGER_CONSTRUCTOR;
+   private static Class<?> FULL_TEXT_ENTITYMANAGER;
    static
    {
       try
@@ -45,17 +44,18 @@
          String version = null;
          try
          {
-            Class<?> searchVersionClass = Class.forName("org.hibernate.search.Version");
-            Field versionField = searchVersionClass.getDeclaredField("VERSION");
-            version = (String) versionField.get(null);
+            Class<?> searchVersionClass = Reflections.classForName("org.hibernate.search.Version");
+            Method versionMethod = searchVersionClass.getDeclaredMethod("getVersionString");
+            version = (String) versionMethod.invoke(null);
          }
          catch (Exception e)
          {
-            log.debug("no Hibernate Search, sorry :-(", e);
+            e.printStackTrace();
+            log.info("no Hibernate Search", e);
          }
          if (version != null)
          {
-            Class<?> searchClass = Class.forName("org.hibernate.search.Search");
+            Class<?> searchClass = Reflections.classForName("org.hibernate.search.Search");
             try
             {
                FULL_TEXT_SESSION_CONSTRUCTOR = searchClass.getDeclaredMethod("getFullTextSession", Session.class);
@@ -65,8 +65,7 @@
                log.debug("org.hibernate.search.Search.getFullTextSession(Session) not found, trying deprecated method name createFullTextSession");
                FULL_TEXT_SESSION_CONSTRUCTOR = searchClass.getDeclaredMethod("createFullTextSession", Session.class);
             }
-            FULL_TEXT_SESSION_PROXY_CLASS = Class.forName("org.jboss.seam.persistence.FullTextHibernateSessionProxy");
-            Class<?> jpaSearchClass = Class.forName("org.hibernate.search.jpa.Search");
+            Class<?> jpaSearchClass = Reflections.classForName("org.hibernate.search.jpa.Search");
             try
             {
                FULL_TEXT_ENTITYMANAGER_CONSTRUCTOR = jpaSearchClass.getDeclaredMethod("getFullTextEntityManager", EntityManager.class);
@@ -76,13 +75,14 @@
                log.debug("org.hibernate.search.jpa.getFullTextSession(EntityManager) not found, trying deprecated method name createFullTextEntityManager");
                FULL_TEXT_ENTITYMANAGER_CONSTRUCTOR = jpaSearchClass.getDeclaredMethod("createFullTextEntityManager", EntityManager.class);
             }
-            FULL_TEXT_ENTITYMANAGER_PROXY_CLASS = Class.forName("org.jboss.seam.persistence.FullTextEntityManagerProxy");
-            log.debug("Hibernate Search is available :-)");
+            FULL_TEXT_ENTITYMANAGER = Reflections.classForName("org.hibernate.search.jpa.FullTextEntityManager");
+            log.info("Hibernate Search is available");
          }
       }
       catch (Exception e)
       {
-         log.debug("no Hibernate Search, sorry :-(", e);
+         e.printStackTrace();
+         log.info("no Hibernate Search", e);
       }
    }
 
@@ -201,7 +201,7 @@
     */
    static Session proxySession(Session session)
    {
-      if (FULL_TEXT_SESSION_PROXY_CLASS == null)
+      if (FULL_TEXT_SESSION_CONSTRUCTOR == null)
       {
          return session;
       }
@@ -243,7 +243,7 @@
    @Override
    public EntityManager proxyEntityManager(EntityManager entityManager)
    {
-      if (FULL_TEXT_ENTITYMANAGER_PROXY_CLASS == null)
+      if (FULL_TEXT_ENTITYMANAGER_CONSTRUCTOR == null)
       {
          return super.proxyEntityManager(entityManager);
       }
@@ -262,6 +262,15 @@
       }
    }
 
+   public Set<Class<?>> getAdditionalEntityManagerInterfaces()
+   {
+      if (FULL_TEXT_ENTITYMANAGER == null)
+      {
+         return Collections.emptySet();
+      }
+      return (Set) Collections.singleton(FULL_TEXT_ENTITYMANAGER);
+   }
+
    /**
     * Occurs when Hibernate is in the classpath, but this particular
     * EntityManager is not from Hibernate

Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java	2010-08-30 07:00:01 UTC (rev 13663)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java	2010-08-30 08:54:49 UTC (rev 13664)
@@ -48,12 +48,12 @@
  */
 public class ManagedPersistenceContextBeanLifecycle implements BeanLifecycle<EntityManager>
 {
+   private static final Logger log = LoggerFactory.getLogger(ManagedPersistenceContextBeanLifecycle.class);
+
    private final Class<?> proxyClass;
 
    private final Constructor<?> proxyConstructor;
 
-   private static final Logger log = LoggerFactory.getLogger(ManagedPersistenceContextBeanLifecycle.class);
-
    private PersistenceContexts persistenceContexts;
 
    private SeamPersistenceProvider persistenceProvider;
@@ -64,10 +64,20 @@
 
    private EntityManagerFactory emf;
 
-   public ManagedPersistenceContextBeanLifecycle(Set<Annotation> qualifiers, ClassLoader loader, BeanManager manager)
+   public ManagedPersistenceContextBeanLifecycle(Set<Annotation> qualifiers, ClassLoader loader, BeanManager manager, Set<Class<?>> additionalinterfaces)
    {
       this.manager = manager;
-      proxyClass = Proxy.getProxyClass(loader, EntityManager.class, Serializable.class, ManagedPersistenceContext.class);
+      Class<?>[] interfaces = new Class[additionalinterfaces.size() + 3];
+      int count = 0;
+      for (Class<?> i : additionalinterfaces)
+      {
+         interfaces[count++] = i;
+      }
+
+      interfaces[count++] = EntityManager.class;
+      interfaces[count++] = Serializable.class;
+      interfaces[count++] = ManagedPersistenceContext.class;
+      proxyClass = Proxy.getProxyClass(loader, interfaces);
       try
       {
          proxyConstructor = proxyClass.getConstructor(InvocationHandler.class);

Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java	2010-08-30 07:00:01 UTC (rev 13663)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java	2010-08-30 08:54:49 UTC (rev 13664)
@@ -132,14 +132,18 @@
 
    public void registerManagedPersistenceContext(Set<Annotation> qualifiers, Class<? extends Annotation> scope, BeanManager manager, ClassLoader loader)
    {
-      // create the new bean to be registerd later
+      // TODO: this is a massive hack. We need a much better way of doing this
+      HibernatePersistenceProvider prov = new HibernatePersistenceProvider();
+      Set<Class<?>> additionalInterfaces = prov.getAdditionalEntityManagerInterfaces();
+      // create the new bean to be registered later
       AnnotatedTypeBuilder<EntityManager> typeBuilder = new AnnotatedTypeBuilder().setJavaClass(EntityManager.class);
       BeanBuilder<EntityManager> builder = new BeanBuilder<EntityManager>(manager).defineBeanFromAnnotatedType(typeBuilder.create());
       builder.setQualifiers(qualifiers);
       builder.setScope(scope);
       builder.getTypes().add(ManagedPersistenceContext.class);
+      builder.getTypes().addAll(additionalInterfaces);
       builder.getTypes().add(Object.class);
-      ManagedPersistenceContextBeanLifecycle lifecycle = new ManagedPersistenceContextBeanLifecycle(qualifiers, loader, manager);
+      ManagedPersistenceContextBeanLifecycle lifecycle = new ManagedPersistenceContextBeanLifecycle(qualifiers, loader, manager, additionalInterfaces);
       builder.setBeanLifecycle(lifecycle);
       beans.add(builder.create());
    }

Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/SeamPersistenceProvider.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/SeamPersistenceProvider.java	2010-08-30 07:00:01 UTC (rev 13663)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/SeamPersistenceProvider.java	2010-08-30 08:54:49 UTC (rev 13664)
@@ -22,6 +22,7 @@
 package org.jboss.seam.persistence;
 
 import java.lang.reflect.Method;
+import java.util.Collections;
 import java.util.Date;
 import java.util.HashSet;
 import java.util.Set;
@@ -235,6 +236,11 @@
       return entityManager;
    }
 
+   public Set<Class<?>> getAdditionalEntityManagerInterfaces()
+   {
+      return Collections.emptySet();
+   }
+
    /**
     * Returns the class of an entity bean instance
     * 

Added: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/HibernateSearchTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/HibernateSearchTest.java	                        (rev 0)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/HibernateSearchTest.java	2010-08-30 08:54:49 UTC (rev 13664)
@@ -0,0 +1,119 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.persistence.test;
+
+import javax.inject.Inject;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+
+import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.queryParser.MultiFieldQueryParser;
+import org.apache.lucene.queryParser.ParseException;
+import org.hibernate.search.jpa.FullTextEntityManager;
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.persistence.PersistenceContextExtension;
+import org.jboss.seam.persistence.transaction.DefaultTransaction;
+import org.jboss.seam.persistence.transaction.SeamTransaction;
+import org.jboss.seam.persistence.transaction.TransactionExtension;
+import org.jboss.seam.persistence.transaction.scope.TransactionScopeExtension;
+import org.jboss.seam.persistence.util.NamingUtils;
+import org.jboss.seam.transactions.test.util.ArtifactNames;
+import org.jboss.seam.transactions.test.util.HelloService;
+import org.jboss.seam.transactions.test.util.IndexedHotel;
+import org.jboss.seam.transactions.test.util.ManagedPersistenceContextProvider;
+import org.jboss.seam.transactions.test.util.MavenArtifactResolver;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.ByteArrayAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+ at RunWith(Arquillian.class)
+public class HibernateSearchTest
+{
+   @Deployment
+   public static Archive<?> createTestArchive()
+   {
+      WebArchive war = ShrinkWrap.createDomain().getArchiveFactory().create(WebArchive.class, "test.war");
+      war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
+      war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
+      war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.HIBERNATE_SEARCH));
+      war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.LUCENE_ANALYZERS));
+      war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.LUCENE_CORE));
+      war.addPackage(TransactionExtension.class.getPackage());
+      war.addPackage(PersistenceContextExtension.class.getPackage());
+      war.addPackage(TransactionScopeExtension.class.getPackage());
+      war.addPackage(NamingUtils.class.getPackage());
+      war.addClasses(HibernateSearchTest.class, IndexedHotel.class, ManagedPersistenceContextProvider.class, HelloService.class);
+      war.addWebResource("META-INF/persistence-search.xml", "classes/META-INF/persistence.xml");
+      war.addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
+      war.addWebResource("META-INF/services/javax.enterprise.inject.spi.Extension", "classes/META-INF/services/javax.enterprise.inject.spi.Extension");
+      return war;
+   }
+
+   @Inject
+   @DefaultTransaction
+   SeamTransaction transaction;
+
+   @Inject
+   FullTextEntityManager em;
+
+   @Test
+   public void testFullTextEntityManager() throws NotSupportedException, SystemException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException
+   {
+      Assert.assertTrue(em instanceof FullTextEntityManager);
+   }
+
+   @Test
+   public void testSearchingForHotel() throws NotSupportedException, SystemException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException, ParseException
+   {
+      transaction.begin();
+      IndexedHotel h = new IndexedHotel("Hilton", "Fake St", "Wollongong", "NSW", "2518", "Australia");
+      em.persist(h);
+      em.flush();
+      transaction.commit();
+
+      transaction.begin();
+      h = new IndexedHotel("Other Hotel", "Real St ", "Wollongong", "NSW", "2518", "Australia");
+      em.persist(h);
+      em.flush();
+      transaction.commit();
+
+      transaction.begin();
+      String[] fields = new String[] { "name" };
+      MultiFieldQueryParser parser = new MultiFieldQueryParser(fields, new StandardAnalyzer());
+      org.apache.lucene.search.Query query = parser.parse("Other");
+
+      // wrap Lucene query in a javax.persistence.Query
+      javax.persistence.Query persistenceQuery = em.createFullTextQuery(query, IndexedHotel.class);
+      IndexedHotel hotel = (IndexedHotel) persistenceQuery.getSingleResult();
+      Assert.assertTrue(hotel.getName().equals("Other Hotel"));
+      transaction.commit();
+
+   }
+}

Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/ArtifactNames.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/ArtifactNames.java	2010-08-30 07:00:01 UTC (rev 13663)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/ArtifactNames.java	2010-08-30 08:54:49 UTC (rev 13664)
@@ -4,5 +4,8 @@
 {
    public static final String WELD_EXTENSIONS = "org.jboss.weld:weld-extensions";
    public static final String SEAM_PERSISTENCE_API = "org.jboss.seam.persistence:seam-persistence-api";
+   public static final String HIBERNATE_SEARCH = "org.hibernate:hibernate-search";
+   public static final String LUCENE_CORE = "org.apache.lucene:lucene-core";
+   public static final String LUCENE_ANALYZERS = "org.apache.lucene:lucene-analyzers";
 
 }

Added: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/IndexedHotel.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/IndexedHotel.java	                        (rev 0)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/IndexedHotel.java	2010-08-30 08:54:49 UTC (rev 13664)
@@ -0,0 +1,236 @@
+/* 
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.seam.transactions.test.util;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+import javax.inject.Inject;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+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.jboss.weld.extensions.core.Veto;
+
+/**
+ * <p>
+ * <strong>Hotel</strong> is the model/entity class that represents a hotel.
+ * </p>
+ * 
+ * @author Gavin King
+ * @author Dan Allen
+ */
+ at Entity
+ at Table(name = "hotel")
+ at Indexed
+ at Veto
+public class IndexedHotel implements Serializable
+{
+   private Long id;
+   private String name;
+   private String address;
+   private String city;
+   private String state;
+   private String zip;
+   private String country;
+   private Integer stars;
+   private BigDecimal price;
+
+   @Inject
+   private HelloService helloService;
+
+   private boolean initalizerCalled = false;
+
+   public IndexedHotel()
+   {
+   }
+
+   @Inject
+   public void create()
+   {
+      initalizerCalled = true;
+   }
+
+   public String sayHello()
+   {
+      return helloService.sayHello();
+   }
+
+   public IndexedHotel(final String name, final String address, final String city, final String state, final String zip, final String country)
+   {
+      this.name = name;
+      this.address = address;
+      this.city = city;
+      this.state = state;
+      this.zip = zip;
+      this.country = country;
+   }
+
+   public IndexedHotel(final int price, final int stars, final String name, final String address, final String city, final String state, final String zip, final String country)
+   {
+      this.price = new BigDecimal(price);
+      this.stars = stars;
+      this.name = name;
+      this.address = address;
+      this.city = city;
+      this.state = state;
+      this.zip = zip;
+      this.country = country;
+   }
+
+   @Id
+   @GeneratedValue
+   public Long getId()
+   {
+      return id;
+   }
+
+   public void setId(final Long id)
+   {
+      this.id = id;
+   }
+
+   @Size(max = 50)
+   @NotNull
+   @Field(index = Index.TOKENIZED, store = Store.NO)
+   public String getName()
+   {
+      return name;
+   }
+
+   public void setName(final String name)
+   {
+      this.name = name;
+   }
+
+   @Size(max = 100)
+   @NotNull
+   public String getAddress()
+   {
+      return address;
+   }
+
+   public void setAddress(final String address)
+   {
+      this.address = address;
+   }
+
+   @Size(max = 40)
+   @NotNull
+   public String getCity()
+   {
+      return city;
+   }
+
+   public void setCity(final String city)
+   {
+      this.city = city;
+   }
+
+   @Size(min = 3, max = 6)
+   @NotNull
+   public String getZip()
+   {
+      return zip;
+   }
+
+   public void setZip(final String zip)
+   {
+      this.zip = zip;
+   }
+
+   @Size(min = 2, max = 10)
+   public String getState()
+   {
+      return state;
+   }
+
+   public void setState(final String state)
+   {
+      this.state = state;
+   }
+
+   @Size(min = 2, max = 40)
+   @NotNull
+   public String getCountry()
+   {
+      return country;
+   }
+
+   public void setCountry(final String country)
+   {
+      this.country = country;
+   }
+
+   @Min(1)
+   @Max(5)
+   public Integer getStars()
+   {
+      return stars;
+   }
+
+   public void setStars(final Integer stars)
+   {
+      this.stars = stars;
+   }
+
+   @Column(precision = 6, scale = 2)
+   public BigDecimal getPrice()
+   {
+      return price;
+   }
+
+   public void setPrice(final BigDecimal price)
+   {
+      this.price = price;
+   }
+
+   @Transient
+   public String getLocation()
+   {
+      return city + ", " + state + ", " + country;
+   }
+
+   @Override
+   public String toString()
+   {
+      return "Hotel(" + name + "," + address + "," + city + "," + zip + ")";
+   }
+
+   @Transient
+   public boolean isInitalizerCalled()
+   {
+      return initalizerCalled;
+   }
+
+}

Added: modules/persistence/trunk/impl/src/test/resources/META-INF/persistence-search.xml
===================================================================
--- modules/persistence/trunk/impl/src/test/resources/META-INF/persistence-search.xml	                        (rev 0)
+++ modules/persistence/trunk/impl/src/test/resources/META-INF/persistence-search.xml	2010-08-30 08:54:49 UTC (rev 13664)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence xmlns="http://java.sun.com/xml/ns/persistence" 
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" 
+   version="2.0">
+   <persistence-unit name="transactionPu">
+      <!--
+      <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+      -->
+      <provider>org.hibernate.ejb.HibernatePersistence</provider>
+      <jta-data-source>java:/DefaultDS</jta-data-source>
+      <class>org.jboss.seam.transactions.test.util.IndexedHotel</class>
+      <exclude-unlisted-classes/>
+      <properties>
+         <!-- Properties for Hibernate (default provider for JBoss AS) -->
+         <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+         <property name="hibernate.show_sql" value="true"/>
+         <!-- Only format when you need to debug, because it slows things down -->
+         <property name="hibernate.format_sql" value="false"/>
+			<property name="hibernate.search.default.directory_provider" 
+			          value="org.hibernate.search.store.FSDirectoryProvider"/> 
+			
+			<property name="hibernate.search.default.indexBase" 
+			          value="/tmp/"/> 
+         <!-- Properties for EclipseLink (default provider for GlassFish) -->
+         <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
+         <property name="eclipselink.logging.level" value="FINE"/>
+      </properties>
+   </persistence-unit>
+</persistence>



More information about the seam-commits mailing list