Skip to content

Instantly share code, notes, and snippets.

@emmanuelbernard
emmanuelbernard / SearchServiceV2.java
Created March 14, 2011 13:58
Version where the faceting filter state is managed by Hibernate Search
/**
* @author Emmanuel Bernard <emmanuel@hibernate.org>
*/
public class SearchServiceV2 {
@Inject
FullTextEntityManager em;
private org.hibernate.search.FullTextQuery ftQuery;
/**
* do the initial query
void doStuff() {
String userQuery = "...";
SearchService search = new SearchService();
//do the query and display it using your favorite tech
List<Car> results = search.searchCar( userQuery );
displayResultsOnScreen( results );
//build the Facet menu and display it
search.displayFacets();
NFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ hibernate-ogm-core ---
[INFO] org.hibernate.ogm:hibernate-ogm-core:jar:3.0.0-SNAPSHOT
[INFO] +- org.hibernate:hibernate-core:jar:3.6.3-SNAPSHOT:compile
[INFO] | +- antlr:antlr:jar:2.7.6:compile
[INFO] | +- commons-collections:commons-collections:jar:3.1:compile
[INFO] | +- dom4j:dom4j:jar:1.6.1:compile
[INFO] | +- org.hibernate:hibernate-commons-annotations:jar:3.2.0.Final:compile
[INFO] | +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.0.Final:compile
[INFO] | \- javax.transaction:jta:jar:1.1:compile
[INFO] +- org.hibernate:hibernate-entitymanager:jar:3.6.3-SNAPSHOT:compile
try {
cfg.configure(
adapter,
Collections.singletonMap( AvailableSettings.VALIDATION_FACTORY, token )
);
+ cfg.buildEntityManagerFactory();
fail( "Was expecting error as token did not implement ValidatorFactory" );
}
catch ( HibernateException e ) {
// probably the condition we want but unfortunately the exception is not specific
sessionFactory.openSession(
new SessionOptionBuilder()
.interceptor(interceptor)
.autoJoin(false)
.get()
)
sessionFactory
.withSessionOptions()
.interceptor(interceptor)
.autoJoin(false)
.openSession();
sessionFactory
.withSessionOptionsFrom(otherSession)
.interceptor(interceptor)
class AddressableObject<T extends Address> {
T getAddress();
}
class IPContainer<IPAddress> {
}
manu@dhcp-193-194 ogm (OGM-30 *) $ mvn dependency:tree
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Hibernate OGM Aggregator
[INFO] Hibernate Object Grid Mapper
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Hibernate OGM Aggregator 3.0.0-SNAPSHOT
//old
public void flush() {
try {
if ( !isTransactionInProgress() ) {
throw new TransactionRequiredException( "no transaction is in progress" );
}
getSession().flush();
}
catch ( RuntimeException e ) {
throw convert( e );
Caused by: org.infinispan.config.ConfigurationException: Component factory class org.infinispan.factories.MarshallerFactory incorrectly registered! Debug stack: null
[java] at org.infinispan.factories.AbstractComponentRegistry.getFactory(AbstractComponentRegistry.java:365)
[java] at org.infinispan.factories.AbstractComponentRegistry.getOrCreateComponent(AbstractComponentRegistry.java:317)
[java] at org.infinispan.factories.AbstractComponentRegistry.invokeInjectionMethod(AbstractComponentRegistry.java:254)
[java] at org.infinispan.factories.AbstractComponentRegistry$Component.injectDependencies(AbstractComponentRegistry.java:843)
[java] at org.infinispan.factories.AbstractComponentRegistry.registerComponent(AbstractComponentRegistry.java:228)
[java] at org.infinispan.factories.ComponentRegistry.registerComponent(ComponentRegistry.java:133)
[java] at org.infinispan.factories.AbstractComponentRegistry.registerComponent(AbstractComponentRegistry.java:185)
[java] at