[Hibernate-JIRA] Created: (HSEARCH-623) Support for faceting search results
by G Fernandes (JIRA)
Support for faceting search results
-----------------------------------
Key: HSEARCH-623
URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-623
Project: Hibernate Search
Issue Type: New Feature
Components: engine
Reporter: G Fernandes
I've been asked more than once about the possibility to support facet retrieval from the search results. The idea is to categorize the results of a query into buckets containing a label plus a number of occurrences. Consider an example: I have a Book entity containing a language field. When I search for Books, I'd like to obtain not only a List<Book>, but also a list of languages and how many books from the search results fit into each of these languages, so that I can render the results as:
Found 17 Books:
English (10)
Italian (5)
Spanish (2)
It'd be also possible to facet on more than a field at the same time, similar to what's being done with projections.
Facet calculation would be done at query time reading directly from the index, probably by using a plugable strategy, examples would be LuceneFieldCacheStrategy and TermEnumStrategy.
Asking for facets would be done at API level, probably with a decorator on top of QueryBuilder something like
facetQueryBuilder.facetOn("field1").facetOn("field2").results().facets();
WDYT?
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years
[Hibernate-JIRA] Created: (HHH-5352) Misleading replacement of commas with cross joins
by Patras Vlad (JIRA)
Misleading replacement of commas with cross joins
-------------------------------------------------
Key: HHH-5352
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5352
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.5.3, 3.5.2, 3.5.1, 3.5.0-Final, 3.5.0-CR-2, 3.5.0-CR-1, 3.5.0-Beta-4, 3.5.0-Beta-3, 3.5.0-Beta-2
Environment: Hibernate 3.5.3
Ms SQL Server 2005
Reporter: Patras Vlad
There was a new feature implemented in 3.5.0-Beta-2: HHH-1480, as a result, for many dialects, the comma operator "," was replaced with "cross join". As it's already obvious from the feature's description, this changes join precedence. If the query contains outer joins (left or right) this replacement changes the results (because outer join precedence is important).
This might not be interpreted as a bug if you know what SQL operator will be generated when you place a comma in HQL, but it's misleading if you don't. A HQL query like:
{noformat}select a from A a, B left join B.c c{noformat}
is not equivalent with the SQL query:
{noformat}select a.* from A.a, B b left join C c on b.cid = c.id{noformat}
because the actual SQL query is:
{noformat}select a.* from A.a cross join B b left join C c on b.cid = c.id{noformat}
The first SQL query would make a left join on B and C and then a cross join with the result and A (and this is what we should expect). The second SQL query makes a cross join on A and B and then a left join with the result and C (this is not expected since we had a comma in HQL).
I understand the issues presented in HHH-1480, but they should be expected, i.e. a developer SHOULD expect a faliure from a query like
{noformat}select a from A a, B b join a.c C{noformat}
because "a" is not visible in the join. Hibernate should not use a cross join behind the scenes to allow such a query at the expense of providing misleading results for others.
Maybe turn this into a feature/improvement or add another to allow explicit comma or croos join in HQL, or support parenthesis in HQL.
The only workaround I can see for now is to re-order the query like this:
{noformat}select a from B left join B.c c, A a{noformat}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years
[Hibernate-JIRA] Created: (HHH-4073) discriminator formula creates problem in hibernate envers
by Saravana Kumar (JIRA)
discriminator formula creates problem in hibernate envers
---------------------------------------------------------
Key: HHH-4073
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4073
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 3.3.x
Environment: hibernate-3.3.x, envers-1.2.1.ga-hibernate-3.3.jar (Oracle 10g or HSQLDB)
Reporter: Saravana Kumar
I map my classes using Single Table per class hierarchy as below
@Entity
@DiscriminatorFormula ("(select t.c_type from t_type t where t.c_id = c_type)")
@Audited
public class Attribute...{
...
}
or
<discriminator type="string">
<formula>(select t.c_type from t_type t where t.c_id = c_type)</formula>
</discriminator>
When I use envers
I get the follwoing error
Caused by: java.lang.ClassCastException: org.hibernate.mapping.Formula
at org.hibernate.envers.configuration.metadata.MetadataTools.addColumns(MetadataTools.java:154)
at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.generateMappingData(AuditMetadataGenerator.java:263)
at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.generateFirstPass(AuditMetadataGenerator.java:345)
at org.hibernate.envers.configuration.EntitiesConfigurator.configure(EntitiesConfigurator.java:87)
at org.hibernate.envers.configuration.AuditConfiguration.(AuditConfiguration.java:86)
at org.hibernate.envers.configuration.AuditConfiguration.getFor(AuditConfiguration.java:99)
at org.hibernate.envers.event.AuditEventListener.initialize(AuditEventListener.java:260)
at org.hibernate.event.EventListeners$1.processListener(EventListeners.java:198)
at org.hibernate.event.EventListeners.processListeners(EventListeners.java:181)
at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:194)
When I tried to debug the problem
(AuditMetadataGenerator.java:263) has
260: // Checking if there is a discriminator column
261: if (hasDiscriminator) {
262: Element discriminator_element = class_mapping.addElement("discriminator");
263: MetadataTools.addColumns(discriminator_element, pc.getDiscriminator().getColumnIterator());
264: discriminator_element.addAttribute("type", pc.getDiscriminator().getType().getName());
265: }
(MetadataTools.java:154) has
152: public static void addColumns(Element any_mapping, Iterator<Column> columns) {
153: while (columns.hasNext()) {
154: Column column = columns.next();
155: addColumn(any_mapping, column.getName(), column.getLength(), column.getScale(), column.getPrecision(),
156: column.getSqlType());
157: }
158: }
I see that there is nothing to handle Formula :-(
Can you investigate?
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years
[Hibernate-JIRA] Created: (HHH-5757) OneToOne SQL missing parameter
by Martin Striz (JIRA)
OneToOne SQL missing parameter
------------------------------
Key: HHH-5757
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5757
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.6.0, 3.5.6
Environment: Hibernate 3.5.6 / 3.6.0
H2 1.2.143 (in-memory) / PostgreSQL 9.0-801.jdbc4
Reporter: Martin Striz
Priority: Critical
Attachments: issue-test-case.zip
Hibernate fails to query OneToOne association from the non-owning side when there is a reference inside the where clause. The behaviour was observed on both Hibernate 3.5.6 and 3.6.0 and tested in H2 and PostgreSQL environments.
Given two entities:
{code:java}
@Entity
public class Frame implements Serializable {
@Id
private long id;
@OneToOne
private Picture picture;
}
@Entity
public class Picture implements Serializable {
@Id
private long id;
@OneToOne(mappedBy = "picture")
private Frame frame;
}
{code}
If the query is issued from the owning side of the association, everything works as expected.
{code}
Picture pictureRef = entityManager.getReference(Picture.class, 5L); // id exists
// list Frames by Picture reference (works)
List<Frame> frames = entityManager.createQuery("from Frame f where f.picture = :picture", Frame.class)
.setParameter("picture", pictureRef)
.getResultList();
{code}
However, if the query is issued from the non-owning side, the exception is thrown.
{code}
Frame frameRef = entityManager.getReference(Frame.class, 3L); // id exists
// list Pictures by Frame reference (crashes!)
List<Picture> pictures = entityManager.createQuery("from Picture p where p.frame = :frame", Picture.class)
.setParameter("frame", frameRef)
.getResultList();
{code}
The stacktrace produced with H2 database used:
{noformat}
javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: could not execute query
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1214)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1147)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:255)
at issue.OneToOneIssueMain.query2(OneToOneIssueMain.java:83)
at issue.OneToOneIssueMain.run(OneToOneIssueMain.java:29)
at issue.OneToOneIssueMain.main(OneToOneIssueMain.java:19)
Caused by: org.hibernate.exception.GenericJDBCException: could not execute query
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2536)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
at org.hibernate.loader.Loader.list(Loader.java:2271)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:452)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1268)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:246)
... 3 more
Caused by: org.h2.jdbc.JdbcSQLException: Parameter "#1" is not set; SQL statement:
select picture0_.id as id1_ from Picture picture0_ where picture0_.id=? [90012-143]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:327)
at org.h2.message.DbException.get(DbException.java:167)
at org.h2.message.DbException.get(DbException.java:144)
at org.h2.expression.Parameter.checkSet(Parameter.java:73)
at org.h2.command.Prepared.checkParameters(Prepared.java:161)
at org.h2.command.CommandContainer.query(CommandContainer.java:79)
at org.h2.command.Command.executeQuery(Command.java:132)
at org.h2.jdbc.JdbcPreparedStatement.executeQuery(JdbcPreparedStatement.java:96)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1953)
at org.hibernate.loader.Loader.doQuery(Loader.java:802)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
at org.hibernate.loader.Loader.doList(Loader.java:2533)
... 11 more
{noformat}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years