[ORM|OGM|Search] Adding an unwrap() new method to org.hibernate.Session
by Sanne Grinovero
I was looking at how Search and OGM benefit from the
SessionDelegatorBaseImpl; extending this base class was a good
progress but there is something missing.
OGM has to still reimplement all methods defined by the EventSource
contract, making the implementation confusing as while it extends the
base delegate it still has to directly delegate for many other
methods.
So my initial impulse was to go and refactor the
SessionDelegatorBaseImpl to actually be an "EventSourceBaseDelegator",
adding the additional interface and delegates for the missing methods.
But questioning why the OGM Session needs to implement EventSource, it
turns out the reason is that when it uses Search this needs to access
the EventSource and will cast the given Session to one; so OGM's
Session has to implement that interface too, only for this reason.
Such a cast has never been dangerous for Search in the past as there
was only one Session but the existence of the SessionDelegatorBaseImpl
in ORM is making it easy to see more Session implementations which
actually don't implement EventSource (and often don't need to).
Rather than forcing / recommending all implementors to consistently
extend EventSource as well, it would be nice to introduce a way to get
a typesafe reference to the only EventSource we need.
My proposal is to add an unwrap() method to the public
org.hibernate.Session, like the one in JPA, and enhance the
implementation of both SessionImpl#unwrap and the
EntityManagerImpl#unwrap() to also satisfy requests for the
EventSource.class, and then possibly other such components as needed.
I would then be able to remove some casts in various places, and OGM's
Session wouldn't need to implement the EventSource interface.
ok?
Thanks,
Sanne
10 years, 7 months
NoSuchMethodError running hibernate-infinispan tests with Infinispan 7.2.1
by Gail Badner
Following Steve's suggestion using resolutionStrategy, I was able to build the hibernate-infinispan jar with Infinispan 6.0.0.Final and run the unit tests with 7.2.1.Final.
I'm sure there's a more elegant way to do this, so I've created a new jira (HHH-9802) and a pull request with the change I made: https://github.com/hibernate/hibernate-orm/pull/955 .
There were actually some unit test failures in InfinispanRegionFactoryTestCase using 7.2.1.Final due to java.lang.NoSuchMethodError.
It happens in assertions like:
assertEquals(5000, cacheCfg.eviction().maxEntries());
The problem is that org.infinispan.configuration.cache.EvictionConfiguration.maxEntries() returns int in 6.0.0.Final, but returns long in 7.2.1.Final. The only usage I see is in the unit tests. I can probably workaround this in the unit test, but I was wondering if this could cause a problem if an application used this method directly.
Galder, do you know if this is a concern?
I have instructions in the pull request for reproducing these failures.
I commented out the failing assertions locally to verify that nothing else causes the test to fail.
I also see org.hibernate.cache.infinispan.TypeOverrides.evictionMaxEntries is defined as an int. That gets initialized based on a value set for on hibernate.cache.infinispan.<classnam>.eviction.max_entries. The only place I see TypeOverrides.getEvictionMaxEntries() used is in InfinispanRegionFactoryTestCase. Does this actually get used anywhere? Does the value find its way into a EvictionConfiguration.maxEntries field? If so, should be a long (instead of an int) in master?
I had a quick chat with Scott Marlow when I realized this was a potential problem and we agreed that it shouldn't block releasing Hibernate ORM 4.3.10.Final. I have gone ahead and released 4.3.10.Final.
I will check in on things Friday morning, but I have to leave by 10:30am and will be off the rest of the day. I can pick this up on Monday if need be.
Regards,
Gail
10 years, 7 months
[OGM] AbstractKey
by Ewa Stawicka
There are three classes AssociationKey, EnityKey, IdSourceKey, which all
contains methods:
public String[] getColumnNames()
public Object[] getColumnValues()
public String getTable()
and we have three methods in couchdb module:
Identifier.createAssociationId, Identifier.createEntityId,
CouchDBDatastore.createId, each one does basicly the same, but takes
different parameter.
Can we extract abstract class AbstractKey, with columnValues field, some
getters, createId method? I will need createId method in couchbase module.
Ewa
10 years, 7 months
AvailableSettings#USE_NEW_ID_GENERATOR_MAPPINGS
by Sanne Grinovero
I just noticed that the ORM testsuite seems to consistently set this
option to "true".
The default being false, the "new" kind is available since ORM 3.2
according to javadoc.
Would this be a good time to switch the default?
10 years, 7 months
[OGM] DocumentStoreConfiguration
by Emmanuel Bernard
So far DocumentStoreConfiguration is very generic and only deals with
remote datastore with reasonable expectations (hosts, ports, usernames.
Cassandra makes use of that class.
Should we rename it and create a subclass for document stores that would
be empty today?
Emmanuel
10 years, 7 months
Search - Plain text and SimpleQueryParser
by Guillaume Smet
Hi,
Having some spare time, I revisited my patch that used the Lucene
SimpleQueryParser to provide more advanced search features to the end user.
At my company, our search requirements are usually the following:
- a full text search on the name and description;
- a set of dropdown choices.
Our full text search uses the AND operator as our customers usually
requires this. It's not something we can do with the current keyword()
search (I described the issue at length in
https://hibernate.atlassian.net/browse/HSEARCH-917).
We often give the ability to use boolean operators and phrase queries to
the end user.
How did we expose this feature? We build a Lucene query using the
MultiFieldsQueryParser and we set the default operator to AND. We can't use
the DSL.
Starting with Lucene 4, we have a nice parser which is called
SimpleQueryParser and which is... simple and resilient. And I think it
would be a good idea to expose it via the DSL.
It currently looks like this:
https://github.com/openwide-java/hibernate-search/commit/ee776744760d8115...
(there's not much code, Lucene is doing the magic).
There are a couple of XXX I would like to discuss and I'm not that thrilled
with the names I gave to the options.
I have some spare time this week and next week so I'll be able to polish
the patch based on your feedback!
Have a nice day.
--
Guillaume
10 years, 7 months
Unable to build local snapshots of ORM 5
by Sanne Grinovero
I need to build local snapshots of ORM to test things with Hibernate
Search, but invoking "publishToMavenLocal" produces an error on the
OSGi module:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task
':hibernate-osgi:publishMavenJavaPublicationToMavenLocal'.
Failed to publish publication 'mavenJava' to repository 'MavenLocal'
> Invalid publication 'mavenJava': artifact file does not exist:
'/home/sanne/workspaces/hibernate/hibernate-core-parent/hibernate-osgi/target/karafFeatures/hibernate-osgi-5.0.0-SNAPSHOT-karaf.xml'
All I know is that indeed that file isn't there.
I tried to workaround the problem by deploying a snapshot to Nexus,
but that failed with a similar error.
10 years, 7 months
SchemaExport usage ?
by Sanne Grinovero
We have some Hibernate Search tests which use multi-tenancy, and
require the schema to be exported explicitly. I'm trying to get these
to run now with Hibernate ORM 5.
I can't use the command line tool, as the test configuration options
should be passed by instance (there are several unit tests to be run,
each with its own configuration).
I already have a SessionFactory started, so I'd prefer to use its
metadata if possible, but while SchemaExport has plenty of
constructors, it doesn't seem to have one I could use.
This one looks like a good candidate:
SchemaExport(ConnectionHelper connectionHelper, MetadataImplementor metadata)
as I do have a ConnectionHelper instance. But while I have a reference
to my SessionFactory, and a reference to the Configuration which
started it, I couldn't find a way to get a MetadataImplementor from
these?
Wouldn't it be very useful to have something like
SchemaExport(ConnectionHelper connectionHelper, SessionFactorty sf) ?
I think all multi-tenancy users would need something similar.
Partially unrelated, the methods:
- org.hibernate.cfg.Configuration.generateDropSchemaScript(Dialect)
- org.hibernate.cfg.Configuration.generateSchemaCreationScript(Dialect)
are returning an hard coded String[0]. Should these be implemented
before 5.0.0.Final, or are these meant to be deprecated?
Thanks,
Sanne
10 years, 7 months
[OGM] Need to list entities when using Hibernate OGM on WildFly
by Gunnar Morling
Hi,
When using Hibernate OGM on WildFly, one needs to list the entity classes
in persistence.xml, otherwise and "Unknown entity" exception will be raised.
Does anyone have a rough idea what may be causing this or where to get
started to analyse this issue?
Thanks,
--Gunnar
10 years, 7 months