[Hibernate-JIRA] Created: (HHH-6574) map-key-many-to-many and cascade="all-delete-orphan" do not work together
by David Bray (JIRA)
map-key-many-to-many and cascade="all-delete-orphan" do not work together
-------------------------------------------------------------------------
Key: HHH-6574
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6574
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.6
Environment: Hibernate 3.6.6 Final
Oracle 11.2.0.2.0
Reporter: David Bray
Priority: Blocker
Attachments: hibtestcase.jar
It seems that if you have maps keyed by entities, they do not respect the cascade options. The attached test case shows this working for Map<String, Entity> but failing for Map<Entity, String> and Map<Entity, Entity> with 'object references an unsaved transient instance'.
The problem seems to be caused by the code treating maps as single type collections. As an example, calling getCollectionPersistor from Cascade for the Map<Entity, String> returns a BasicCollectionPersistor for String. The element type for the persistor is then claimed to be String and any cascading which should be performed on the key is ignored.
To pre-empt a solution I suspect will be proposed, I can't use nested components as the map keys as the objects these entities will represent in our system tend to be complex, self-referential hierarchies of arbitrary depth.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 5 months
[Hibernate-JIRA] Commented: (HHH-1400) Using formula-based property causes invalid SQL code for children "subselect" query
by Golubev Dmitriy (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1400?page=c... ]
Golubev Dmitriy commented on HHH-1400:
--------------------------------------
the problem is not fixed (3.6.6)
i have several entities with hierarchy
1. Project
2. Measure
3. Activity
where i used formula on time status field via attribute @Formula.
formula is complex sql, which contains "case when" with logical expressions and "exist select from".
when measure object is loaded by usual detachedcriteria activities are loaded by collection initialization
in SubselectFetch where condition is formed by subtring using " from ". but in sql i have several "select from ". and sql is trimmed with error conditions.
so initial sql which is processed in SubselectFetch constructor (unnecessary fields are skipped)
"select (
case
when
(
this_.mctmea_status in ( 'IN_CREATION' ) and
this_.mctmea_plannedstartdate is not null and
trunc(this_.mctmea_plannedstartdate) < trunc(sysdate)
)
then 'ATTENTION'
when
(
this_.mctmea_status in ('IN_CREATION', 'STARTED', 'IN_PROGRESS') and
this_.mctmea_plannedenddate is not null and
trunc(this_.mctmea_plannedenddate) < trunc(sysdate)
)
then 'ATTENTION'
when
(
exists
(
select mcta.id from mct_activity mcta
where
(
mcta.mctact_status = 'IN_CREATION' and
mcta.mctact_planstartdate is not null and
trunc(mcta.mctact_planstartdate) < trunc(sysdate)
)
and mcta.FKMCTACT_MEA_ID = this_.id
)
)
then 'ATTENTION'
when
(
exists
(
select mcta.id from mct_activity mcta
where
(
mcta.mctact_status in ('IN_CREATION', 'STARTED', 'IN_PROGRESS') and
mcta.mctact_planenddate is not null and
trunc(mcta.mctact_planenddate) < trunc(sysdate)
)
and mcta.FKMCTACT_MEA_ID = this_.id
)
)
then 'ATTENTION'
when
(
this_.mctmea_status in ( 'IN_CREATION' ) and
this_.mctmea_plannedstartdate is not null and
trunc(this_.mctmea_plannedstartdate)=trunc(sysdate)
)
then 'WARNING'
when
(
this_.mctmea_status in ('STARTED', 'IN_PROGRESS') and
this_.mctmea_plannedenddate is not null and
trunc(this_.mctmea_plannedenddate) = trunc(sysdate)
)
then 'WARNING'
when
(
exists
(
select mcta.id from mct_activity mcta
where
(
mcta.mctact_status = 'IN_CREATION' and
mcta.mctact_planstartdate is not null and
trunc(mcta.mctact_planstartdate)=trunc(sysdate)
)
and mcta.FKMCTACT_MEA_ID = this_.id
)
)
then 'WARNING'
when
(
exists
(
select mcta.id from mct_activity mcta
where
(
mcta.mctact_status in ('STARTED', 'IN_PROGRESS') and
mcta.mctact_planenddate is not null and
trunc(mcta.mctact_planenddate)=trunc(sysdate)
)
and mcta.FKMCTACT_MEA_ID = this_.id
)
)
then 'WARNING'
else 'OK'
end
) as formula8_7_ from DGVSRM.MCT_MEASURE this_ left outer join DGVSRM.MCT_MFOCUS mctmainfoc2_ on this_.FKMCTMEA_MFOCUS_ID=mctmainfoc2_.ID left outer join DGVSRM.UIMLString uimultilan3_ on mctmainfoc2_.MCTMF_MLNAME=uimultilan3_.ID left outer join DGVSRM.MCT_MATLEVEL mctmaturit4_ on this_.FKMCTMEA_MATLEVEL_ID=mctmaturit4_.ID left outer join DGVSRM.UIMLString uimultilan5_ on mctmaturit4_.MCTML_MLDESCRIPTION=uimultilan5_.ID left outer join DGVSRM.UIMLString uimultilan6_ on mctmaturit4_.MCTML_MLNAME=uimultilan6_.ID inner join DGVSRM.MCT_TYPE mcttype7_ on this_.FKMCTMEA_TYPE_ID=mcttype7_.ID left outer join DGVSRM.NOTIFICATION_BUNDLE notificati8_ on mcttype7_.FKMCTTYP_NBUNDLE_ID=notificati8_.ID where this_.FKMCTMEA_PROJ_ID=? and this_.deleteFlag=?"
result queryString is
"
from mct_activity mcta
where
(
mcta.mctact_status = 'IN_CREATION' and
mcta.mctact_planstartdate is not null and
trunc(mcta.mctact_planstartdate) < trunc(sysdate)
)
and mcta.FKMCTACT_MEA_ID = this_.id
)
)
then 'ATTENTION'
when
(
exists
(
select mcta.id from mct_activity mcta
where
(
mcta.mctact_status in ('IN_CREATION', 'STARTED', 'IN_PROGRESS') and
mcta.mctact_planenddate is not null and
trunc(mcta.mctact_planenddate) < trunc(sysdate)
)
and mcta.FKMCTACT_MEA_ID = this_.id
)
)
then 'ATTENTION'
when
(
this_.mctmea_status in ( 'IN_CREATION' ) and
this_.mctmea_plannedstartdate is not null and
trunc(this_.mctmea_plannedstartdate)=trunc(sysdate)
)
then 'WARNING'
when
(
this_.mctmea_status in ('STARTED', 'IN_PROGRESS') and
this_.mctmea_plannedenddate is not null and
trunc(this_.mctmea_plannedenddate) = trunc(sysdate)
)
then 'WARNING'
when
(
exists
(
select mcta.id from mct_activity mcta
where
(
mcta.mctact_status = 'IN_CREATION' and
mcta.mctact_planstartdate is not null and
trunc(mcta.mctact_planstartdate)=trunc(sysdate)
)
and mcta.FKMCTACT_MEA_ID = this_.id
)
)
then 'WARNING'
when
(
exists
(
select mcta.id from mct_activity mcta
where
(
mcta.mctact_status in ('STARTED', 'IN_PROGRESS') and
mcta.mctact_planenddate is not null and
trunc(mcta.mctact_planenddate)=trunc(sysdate)
)
and mcta.FKMCTACT_MEA_ID = this_.id
)
)
then 'WARNING'
else 'OK'
end
) as formula8_7_ from DGVSRM.MCT_MEASURE this_ left outer join DGVSRM.MCT_MFOCUS mctmainfoc2_ on this_.FKMCTMEA_MFOCUS_ID=mctmainfoc2_.ID left outer join DGVSRM.UIMLString uimultilan3_ on mctmainfoc2_.MCTMF_MLNAME=uimultilan3_.ID left outer join DGVSRM.MCT_MATLEVEL mctmaturit4_ on this_.FKMCTMEA_MATLEVEL_ID=mctmaturit4_.ID left outer join DGVSRM.UIMLString uimultilan5_ on mctmaturit4_.MCTML_MLDESCRIPTION=uimultilan5_.ID left outer join DGVSRM.UIMLString uimultilan6_ on mctmaturit4_.MCTML_MLNAME=uimultilan6_.ID inner join DGVSRM.MCT_TYPE mcttype7_ on this_.FKMCTMEA_TYPE_ID=mcttype7_.ID left outer join DGVSRM.NOTIFICATION_BUNDLE notificati8_ on mcttype7_.FKMCTTYP_NBUNDLE_ID=notificati8_.ID where this_.FKMCTMEA_PROJ_ID=? and this_.deleteFlag=?"
please provide the solution
> Using formula-based property causes invalid SQL code for children "subselect" query
> -----------------------------------------------------------------------------------
>
> Key: HHH-1400
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1400
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.1 rc3
> Environment: Hibernate 3.0.5, Hibernate 3.1rc3
> Oracle 8i
> Reporter: Chris Rogers
> Attachments: SubselectFetch.java, SubselectFormulaBug.zip, subselectformula.zip
>
>
> I have simple one-to-many relationship, mapped as set:
> <class name="Parent">
> <set name="children" lazy="false" fetch="subselect">
> <key column="PARENT_OID"/>
> <one-to-many class="Child"/>
> </set>
> </class>
> this works fine, constructing subselect SQL which looks like (e.g. for HQL query "from Parent"):
> select <child fields> from <child table> where child.PARENT_OID in (select this_.OID from PARENT this_)
> (simplified)
> However, when adding a formula-based property into Parent:
> <property name="myFormulaField" formula="(complex_select )"/>
> Now SQL becomes:
> select <child fields> from <child table> where PARENT_OID in (complex_select) as formula0_1_, <some parent fields> from PARENT this_)
> This SQL fails because of incorrect grammar (it also seems that backet is missing).
> This is something weird, because subselect fetching only needs Parent's identity column, not any other properties. And I don't think it should be affected by Parent's formula-based properties.
> I can provide more details if necessary, I stripped out all extra mapping/SQL stuff because it seems to be irrelevant here.
> This bug appeared in 3.0.5 later I've downloaded 3.1rc3 and it also fails.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 5 months
[Hibernate-JIRA] Created: (EJB-364) Composite PK and @GeneratedValue
by Radosław Smogura (JIRA)
Composite PK and @GeneratedValue
--------------------------------
Key: EJB-364
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-364
Project: Hibernate Entity Manager
Issue Type: Bug
Affects Versions: 3.3.2.GA
Environment: Hibernate 3.2.6
Glassfish
PostgreSQL
Reporter: Radosław Smogura
Priority: Critical
[code]
For class like this
@Entity
@IdClass(FooId.class)
/* Seq / Table generator */
public class Foo {
int id1;
int id2;
@Id
public getId1() {
return id1;
}
public setId1(....);
@Id
@GeneratedValue(strategy=AUTO/IDENTITY/SEQUENCE/TABLE)
public int getId2() {
return id2;
}
public void setId2(.....);
}
[/code]
Id1 is set manully, but id2 is unchanged i this situation hibernate doesn't generates PK and tries to insert NULL causing error.
Specification requires assigning of generated value with @Id properties. Part 2.4.1 defines two types of PKs simple and composite and part 9.1.9 says about PKs in generally. (SEQ or IDENTITY is specification depended, but PostgreSQL support it and Hibernate should support it too).
--
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
13 years, 5 months
[Hibernate-JIRA] Created: (HHH-6568) QueryStatistics's getExecutionMinTime() return Long.MAX_VALUE instead of zero when execution count is zero and cache hit is greater than zero
by Julien Kronegg (JIRA)
QueryStatistics's getExecutionMinTime() return Long.MAX_VALUE instead of zero when execution count is zero and cache hit is greater than zero
---------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-6568
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6568
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 4.0.0.Beta5, 3.6.6, 3.3.1
Environment: Hibernate (at least 4.0.0 Beta5, 3.6.6, 3.3.1), EhCache 2.4.3, JGroups 2.12.1, DB2
Reporter: Julien Kronegg
Priority: Minor
h3. Introduction / Summary
QueryStatistics initializes the {{executionMinTime}} field to {{Long.MAX_VALUE}}. When the execution count is zero, this causes {{getExecutionMinTime()}} to return {{Long.MAX_VALUE}} instead of an expected value of 0 because the initial value has not yet been updated but a cache hit has already been done.
h3.Test case
This can occur with two applications based on Hibernate and having its EhCache synchronized in replication mode (e.g. using JGroups): the first application does a query with query cache enabled (generates a miss, an execution and a put in the query statistics), then second application query cache is synchronized by replication of the query result (an implicit put without updating the second application query statistics). Finally, the second application does the same query (this generates a hit, but no execution): getting the minimum execution time will return {{Long.MAX_VALUE}}.
h3. Location in the source code
The issue occurs in the new [Hibernate 4 Beta's ConcurrentQueryStatisticsImpl|https://github.com/hibernate/hibernate-core...] as well as in current [Hibernate 3.6's QueryStatisticsImpl|https://github.com/hibernate/hibernate-core/blob/3.6/...] and in older versions, e.g. [Hibernate 3.3's QueryStatistics|https://github.com/hibernate/hibernate-core/blob/3.3/core...].
h3. Solution
To be corrected, {{getExecutionMinTime}} should be corrected to return the executionMinTime only if the execution count is greater than zero, otherwise it should return zero. For example in Hibernate 3.6:
{code}
public long getExecutionMinTime() {
return executionMinTime;
}
{code}
should be replaced by
{code}
public long getExecutionMinTime() {
return (executionCount>0?executionMinTime:0);
}
{code}
Also the {{toString()}} method should call the {{getExecutionMinTime()}} method instead of using the underlying {{executionMinTime}} field.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 5 months
[Hibernate-JIRA] Created: (JPA-18) indexed column treated like a PK
by Cristian Jujea (JIRA)
indexed column treated like a PK
--------------------------------
Key: JPA-18
URL: http://opensource.atlassian.com/projects/hibernate/browse/JPA-18
Project: Java Persistence API
Issue Type: Bug
Affects Versions: 1.0.0
Environment: JPA 2.0 with hibernate as provider, Glassfish3.1, MySQL 5.1
Reporter: Cristian Jujea
I have a rather simple table:
CREATE TABLE ShopOrder(
shopOrderId MEDIUMINT AUTO_INCREMENT PRIMARY KEY,
......
shopperId MEDIUMINT,
INDEX(shopperId)
);
The JPA Entity is:
@Entity
@Table(name = "shoporder")
@Access(AccessType.FIELD)
@NamedQueries({
@NamedQuery(name = "ShopOrder.countOrdersByShopperId", query = "SELECT COUNT(*) FROM ShopOrder s WHERE shopperId = :shopperId")})
public class ShopOrder implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer shopOrderId;
.....
@Column(name="shopperId")
private Integer shopperId;
//getters and setters
}
The code that throws the error:
@Stateless
public class ShopperFacade implements ShopperFacadeRemote {
@PersistenceContext(unitName="WebShopEJBPU")
EntityManager entityManager;
@Override
public int createOrder(int shopperId, String... args) {
ShopOrder shopOrder = new ShopOrder();
shopOrder.setAmount("0");
List<String> items = new ArrayList<String>();
for(int i = 1; i < args.length; i++)
items.add(args[i]);
shopOrder.setItems(items);
shopOrder.setShopperId(shopperId);
entityManager.persist(shopOrder);
entityManager.flush();
return shopOrder.getShopOrderId();
}
The error:
javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist: shop.entities.shopper.ShopOrder
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1215)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1148)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1154)
at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:678)
at com.sun.enterprise.container.common.impl.EntityManagerWrapper.persist(EntityManagerWrapper.java:269)
at shop.ejb.ShopperFacade.createOrder(ShopperFacade.java:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1052)
at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1124)
at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:5367)
at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:619)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:801)
at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:571)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doAround(SystemInterceptorProxy.java:162)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:144)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:862)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:801)
at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:371)
at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:5339)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:5327)
at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:206)
... 19 more
Caused by: org.hibernate.PersistentObjectException: detached entity passed to persist: shop.entities.shopper.ShopOrder
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:127)
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:61)
at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:808)
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:782)
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:786)
at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:672)
... 43 more
The problem does not occur if the line of code setting the shopperId is commented, as such:
@Override
public int createOrder(int shopperId, String... args) {
ShopOrder shopOrder = new ShopOrder();
shopOrder.setAmount("0");
List<String> items = new ArrayList<String>();
for(int i = 1; i < args.length; i++)
items.add(args[i]);
shopOrder.setItems(items);
//shopOrder.setShopperId(shopperId);
entityManager.persist(shopOrder);
entityManager.flush();
return shopOrder.getShopOrderId();
}
If I change the code as such:
ShopOrder shopOrder = new ShopOrder();
shopOrder.setAmount("0");
List<String> items = new ArrayList<String>();
for(int i = 1; i < args.length; i++)
items.add(args[i]);
shopOrder.setItems(items);
entityManager.persist(shopOrder);
entityManager.flush();
shopOrder.setShopperId(shopperId);
entityManager.merge(shopOrder);
entityManager.flush();
I get
javax.persistence.PersistenceException: org.hibernate.HibernateException: identifier of an instance of shop.entities.shopper.ShopOrder was altered from 11 to 12
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1215)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1148)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1154)
at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:798)
at com.sun.enterprise.container.common.impl.EntityManagerWrapper.flush(EntityManagerWrapper.java:418)
at shop.ejb.ShopperFacade.createOrder(ShopperFacade.java:125)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.glassfish.ejb.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1052)
at org.glassfish.ejb.security.application.EJBSecurityManager.invoke(EJBSecurityManager.java:1124)
at com.sun.ejb.containers.BaseContainer.invokeBeanMethod(BaseContainer.java:5367)
at com.sun.ejb.EjbInvocation.invokeBeanMethod(EjbInvocation.java:619)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:801)
at com.sun.ejb.EjbInvocation.proceed(EjbInvocation.java:571)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doAround(SystemInterceptorProxy.java:162)
at com.sun.ejb.containers.interceptors.SystemInterceptorProxy.aroundInvoke(SystemInterceptorProxy.java:144)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.ejb.containers.interceptors.AroundInvokeInterceptor.intercept(InterceptorManager.java:862)
at com.sun.ejb.containers.interceptors.AroundInvokeChainImpl.invokeNext(InterceptorManager.java:801)
at com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:371)
at com.sun.ejb.containers.BaseContainer.__intercept(BaseContainer.java:5339)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:5327)
at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:206)
... 19 more
Caused by: org.hibernate.HibernateException: identifier of an instance of shop.entities.shopper.ShopOrder was altered from 11 to 12
at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId(DefaultFlushEntityEventListener.java:85)
at org.hibernate.event.def.DefaultFlushEntityEventListener.getValues(DefaultFlushEntityEventListener.java:190)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:147)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:219)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:99)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:795)
... 43 more
It is as if the indexed column is treated like a PK
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 5 months
[Hibernate-JIRA] Created: (HSEARCH-776) maxFacetCount returns incorrect results when ordering a faceted query
by Adrian Meredith (JIRA)
maxFacetCount returns incorrect results when ordering a faceted query
---------------------------------------------------------------------
Key: HSEARCH-776
URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-776
Project: Hibernate Search
Issue Type: Bug
Components: query
Affects Versions: 3.4.0.Final
Environment: hibernate 3.6.4, hibernate search 3.4
Reporter: Adrian Meredith
Priority: Critical
When putting a restriction on facets such as
{code}
FacetingRequest fr = qb.facet().name("name").onField("someField").discrete().orderedBy(FacetSortOrder.COUNT_DESC).maxFacetCount(10).includeZeroCounts(false).createFacetingRequest();
{code}
I would expect the facets with the top 10 results to be returned which appears to be true but it seems some are randomly missing (like the 10 are somehow spread across all results as opposed to the top ten). Removing the max restriction and only returning the first ten entries shows the correct results.
for example
{code}
QueryBuilder qb = ftEm.getSearchFactory().buildQueryBuilder().forEntity(WebResult.class).get();
FacetManager fm = query.getFacetManager()
FacetingRequest fr = qb.facet().name("name").onField("someField.id").discrete().orderedBy(FacetSortOrder.COUNT_DESC).includeZeroCounts(false).createFacetingRequest();
fm.enableFaceting(fr);
fm.getFacets("name").subList(0, endIndex);
{code}
The two code examples should return the exact same thing but the don't. The below code is my workaround but as you can imaging this could potentially take a dangerous amount of memory due to it effectively loading the entire index.
My WebResult class has OneToOne relations to various other objects (e.g. country)
--
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
13 years, 5 months
[Hibernate-JIRA] Created: (HHH-6567) SQLServer2005 Dialect creates invalid paging SQL for Native Queries.
by Jonathan Crabtree (JIRA)
SQLServer2005 Dialect creates invalid paging SQL for Native Queries.
--------------------------------------------------------------------
Key: HHH-6567
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-6567
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.4
Environment: Hibernate 3.6.4, MS SQL Server 2005
Reporter: Jonathan Crabtree
With the following code..
SQLQuery query = getSession()
.createSQLQuery("SELECT DISTINCT a.* FROM table_a a LEFT OUTER JOIN table_b b ON a.id = b.ref_id WHERE (a.sequence = 0 AND (b.status = 'X'))");
query.addEntity("entry", EntryStaging.class);
query.setFirstResult(startIndex);
query.setMaxResults(count);
List result = query.list();
Hibernate creates the following SQL..
WITH query AS (select ROW_NUMBER() OVER (ORDER BY CURRENT_TIMESTAMP) as __hibernate_row_nr__, a.* from table_a a left outer join table_b b on a.id = b.ref_id where (a.sequence = 0 and (b.status = 'X')) group by a.* ) SELECT * FROM query WHERE __hibernate_row_nr__ BETWEEN ? AND ?
Which throws the following exception..
hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92)
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.custom.CustomLoader.list(CustomLoader.java:316)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1842)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:157)
at ...(xx.java:164)
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near '*'.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(Unknown Source)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(Unknown Source)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76)
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)
... 14 more
This is due to the group by using * which MS SQL Server does not accept.
A workaround is to list all columns in the query.
Also, I had tried to work-around this problem by including the distinct in a sub query..
SELECT c.* FROM (SELECT DISTINCT a.* FROM table_a a LEFT OUTER JOIN table_b b ON a.id = b.ref_id WHERE (a.sequence = 0 AND (b.status = 'X'))) c
but hibernate produced this sql..
WITH query AS (select ROW_NUMBER() OVER (ORDER BY CURRENT_TIMESTAMP) as __hibernate_row_nr__, c.* from (select a.* from table_a a left outer join table_b b on a.id = b.ref_id where (a.sequence = 0 and (b.status = 'X'))) c group by c.* ) SELECT * FROM query WHERE __hibernate_row_nr__ BETWEEN ? AND ?
Looks like it has done a global search for the select distinct, instead of only checking at the 1st level.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
13 years, 5 months