[Hibernate-JIRA] Created: (HHH-2900) Autodiscovery results ignored by scroll()
by Sergey Koshcheyev (JIRA)
Autodiscovery results ignored by scroll()
-----------------------------------------
Key: HHH-2900
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2900
Project: Hibernate3
Issue Type: Bug
Components: query-hql, query-sql
Affects Versions: 3.2.4.sp1
Reporter: Sergey Koshcheyev
Priority: Minor
Running this piece of code:
session.createSQLQuery("create table tab(col integer)").executeUpdate();
session.createSQLQuery("insert into tab values (1)").executeUpdate();
ScrollableResults sr = session
.createSQLQuery("select col from tab")
.addScalar("col")
.scroll(ScrollMode.FORWARD_ONLY);
sr.next();
sr.getInteger(0);
produces java.lang.NullPointerException
at org.hibernate.impl.AbstractScrollableResults.getFinal(AbstractScrollableResults.java:126)
at org.hibernate.impl.AbstractScrollableResults.getInteger(AbstractScrollableResults.java:208)
The problem seems to be Loader.scroll() is using its returnTypes parameter when instantiating ScrollableResultsImpl instead of letting CustomLoader use its autodiscovered resultTypes array.
A workaround seems to be to use ScrollableResults.get(int) since it doesn't rely on type information.
--
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
17 years
[Hibernate-JIRA] Commented: (HHH-1829) Allow join on any property using property-ref
by Sergey Y Khilkov (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1829?page=c... ]
Sergey Y Khilkov commented on HHH-1829:
---------------------------------------
Hello! Any progress on this issue? I'm using 3.5.2ga and property-ref doesn't work inside joined-subclass key tag..... please, help me anybody....
> Allow join on any property using property-ref
> ---------------------------------------------
>
> Key: HHH-1829
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1829
> Project: Hibernate3
> Issue Type: New Feature
> Components: metamodel
> Affects Versions: 3.2.0 cr1, 3.2.0.cr2
> Reporter: Maarten Winkels
> Assignee: Steve Ebersole
> Attachments: AbstractJoinTest.java, HHH-1829-mwinkels.patch, hhh-1829.patch, JoinNoPropertyRefTest.java, JoinPropertyRefTest.java, Person.hbm.xml, Person.java, PersonNoPropertyRef.hbm.xml
>
>
> Currently joining tables for one class (uing the <join...> tag) is only supported for the id property. The property-ref is allowed on the <key..> tag inside the <join..> tag, but this is ignored.
--
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
17 years
[Hibernate-JIRA] Created: (HHH-2898) Incorrect SQL generated when one-to-many foreign key is in a discriminated subclass table
by Nicolas De Cubber (JIRA)
Incorrect SQL generated when one-to-many foreign key is in a discriminated subclass table
-----------------------------------------------------------------------------------------
Key: HHH-2898
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2898
Project: Hibernate3
Issue Type: Bug
Components: core, query-hql
Environment: Hibernate Tools 3.2.0.beta8
Reporter: Nicolas De Cubber
I have the following mappings describing a hierarchy of events and a class that the events refer to:
<hibernate-mapping package="com.xyz">
<class name="Event" table="event">
<meta attribute="scope-class" inherit="false">public abstract</meta>
<id name="Id" type="long" column="event_id"/>
<discriminator column="event_type_id" type="integer" />
<subclass name="EventPayer" discriminator-value="-3">
<join table="event_payer">
<key column="event_id" />
</join>
</subclass>
</class>
<class name="Payer" table="payer">
<id name="payerId" column="payer_id" type="java.lang.Long"/>
<list name="eventPayers" cascade="save-update">
<key column="payer_id"/>
<list-index column="LISTINDEX"/>
<one-to-many class="EventPayer"/>
</set>
</class>
</hibernate-mapping>
when, in the Hibernate Console, i run the query :
select 1 from Payer payer inner join payer.eventPayers
It generates the following sql-code :
select
1 as col_0_0_
from
Payer payer0_
inner join
Event event1_
on payer0_.payerId=event1_.payer_id
inner join
EventPayer event1_1_
on event1_.event_id=event1_1_event_id
Which is incorrect because the table Event do not have the colum payerId.
The correct query should be like:
select
1 as col_0_0_
from
Payer payer0_
inner join
EventPayer event1_
on payer0_.payerId=event1_.payer_id
inner join
Event event1_1_
on event1_.event_id=event1_1_event_id
I found a 'workaround' but it has performance consequences.
The workAround is to remove the discriminator and to use <joined-subclass> instead of [<subclass> <join>]
So if i rewrite the Event mapping like this:
<class name="Event" table="event">
<meta attribute="scope-class" inherit="false">public abstract</meta>
<id name="Id" type="long" column="event_id"/>
<joined-subclass name="EventPayer" table="event_payer">
<key column="event_id" />
</joined-subclass>
</class>
the query is generated correctly :
select
1 as col_0_0_
from
Payer payer0_
inner join
EventPayer event1_
on payer0_.payerId=event1_.payer_id
inner join
Event event1_1_
on event1_.event_id=event1_1_event_id
--
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
17 years
[Hibernate-JIRA] Commented: (HHH-1901) Filtering on superclass property problem
by Nicolas (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1901?page=c... ]
Nicolas commented on HHH-1901:
------------------------------
Using Hibernate 3.2.4ga
Database : Oracle 10gR2 or MySQL 5.0.27
I've got the same kind of problem with the following mapping :
<hibernate-mapping default-access="field">
<class name="org.escapek.core.domain.Node" table="NODES">
<id name="Id" column="NODE_ID">
<generator class="uuid"/>
</id>
<property name="instanceName" column="INSTANCE_NAME"/>
<property name="creationDate" column="CREATION_DATE"/>
<property name="lastModifiedDate" column="LAST_MODIFIED_DATE"/>
<property name="deletedDate" column="DELETE_DATE"/>
<property name="status" column="STATUS"/>
<many-to-one name="owner" column="OWNER_FK" lazy="false" />
<many-to-one name="creationUser" column="CREATION_USER_FK" lazy="false" />
<many-to-one name="lastModifiedUser" column="LAST_MODIFIED_USER_FK" lazy="false" />
<many-to-one name="deleteUser" column="DELETE_USER_FK" lazy="false" />
<set name="notes" inverse="true">
<key column="COMMENTED_NODE_FK"/>
<one-to-many class="org.escapek.core.domain.Comment"/>
</set>
<joined-subclass name="org.escapek.core.objectmanager.domain.MOFLibrary" table="MOF_LIBRARY">
<key column="NODE_ID"/>
<property name="name" column="NAME"/>
<property name="description" column="DESCRIPTION"/>
<many-to-one name="parentLibrary" column="PARENT_LIBRARY_FK" lazy="false" />
<map name="childrenLibs" inverse="true" lazy="true">
<key column="PARENT_LIBRARY_FK"/>
<map-key column="name" type="string"/>
<one-to-many class="org.escapek.core.objectmanager.domain.MOFLibrary"/>
<filter name="nodeStatus" condition=":nodeStatusParam = STATUS"/>
</map>
<map name="childrenFiles" inverse="true" lazy="true">
<key column="LIBRARY_FK"/>
<map-key column="name" type="string"/>
<one-to-many class="org.escapek.core.objectmanager.domain.MOFFile"/>
<filter name="nodeStatus" condition=":nodeStatusParam = STATUS"/>
</map>
</joined-subclass>
<joined-subclass name="org.escapek.core.objectmanager.domain.MOFFile" table="MOF_FILE">
<key column="NODE_ID"/>
<property name="name" column="NAME"/>
<property name="description" column="DESCRIPTION"/>
<many-to-one name="library" column="LIBRARY_FK" lazy="false" />
<property name="content" column="CONTENT" type="text" length="100000"/>
</joined-subclass>
<filter name="nodeStatus" condition=":nodeStatusParam = STATUS"/>
</class>
<filter-def name="nodeStatus">
<filter-param name="nodeStatusParam" type="string"/>
</filter-def>
</hibernate-mapping>
Whenever I access a node subclass is loaded or when the MOFLibrary collection are loaded, I get the same kind of error saying that column status is undefined. I think this is the same error as already reported by Juan. Here the SQL code generated:
select
childrenfi0_.LIBRARY_FK as LIBRARY4_1_,
childrenfi0_.NODE_ID as NODE1_1_,
childrenfi0_.name as name1_,
childrenfi0_.NODE_ID as NODE1_0_0_,
childrenfi0_1_.INSTANCE_NAME as INSTANCE2_0_0_,
childrenfi0_1_.CREATION_DATE as CREATION3_0_0_,
childrenfi0_1_.LAST_MODIFIED_DATE as LAST4_0_0_,
childrenfi0_1_.DELETE_DATE as DELETE5_0_0_,
childrenfi0_1_.STATUS as STATUS0_0_,
childrenfi0_1_.OWNER_FK as OWNER7_0_0_,
childrenfi0_1_.CREATION_USER_FK as CREATION8_0_0_,
childrenfi0_1_.LAST_MODIFIED_USER_FK as LAST9_0_0_,
childrenfi0_1_.DELETE_USER_FK as DELETE10_0_0_,
childrenfi0_.NAME as NAME17_0_,
childrenfi0_.DESCRIPTION as DESCRIPT3_17_0_,
childrenfi0_.LIBRARY_FK as LIBRARY4_17_0_,
childrenfi0_.CONTENT as CONTENT17_0_
from
MOF_FILE childrenfi0_ inner join NODES childrenfi0_1_ on childrenfi0_.NODE_ID=childrenfi0_1_.NODE_ID
where
:nodeStatus.nodeStatusParam = childrenfi0_.STATUS
and
childrenfi0_.LIBRARY_FK=?
This clearly shows that status column is prefixed with the alias of joined-subclass table instead of the master class.
Hope this will help.
> Filtering on superclass property problem
> ----------------------------------------
>
> Key: HHH-1901
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1901
> Project: Hibernate3
> Issue Type: Bug
> Affects Versions: 3.1.3
> Environment: Hibernate 3.1.3 on Oracle 9i
> Reporter: Juan Ignacio Cidre
> Attachments: test.tar.gz
>
>
> I have three classes Order, Advertisements and Creatives.
> Advertisements is subclass of Creatives
> Order has a one-to-many to Advertisements
> That one-to-many has a filter. The condition has to do with a property of Creative, the Advertisements superclass.
> This is the Order to Advertisements mapping with a filter on deletionStatusId that is a field of Creative.
> <set name="ads" inverse="true" lazy="true">
> <key column="orderId"/>
> <one-to-many class="com.inceptor.domain.msn.Advertisement"/>
> <filter name="deletionStatusFilter" condition="deletionStatusId = 0"/>
> </set>
> This is the Creative mapping with the deletionStatusId, which is mapped as a component. It is a Enum in Java.
> <component name="deletionStatus"
> class="com.inceptor.domain.core.DeletionStatusType">
> <property name="number" column="deletionStatusId" />
> </component>
> I would expected an sql that appends a where condition like [superclass (Creative) table alias].deletionStatusId instead I received [subclass (Advertisements) table alias].deletionStatusId
> This generates a DB error.
> Follows the generated query
> Note ads0_ instead of ads0_1_
> select ads0_.orderId as orderId1_, ads0_.id as id1_, ads0_.id as ID324_0_, ads0_1_.version as version324_0_, ads0_1_.searchEngineAccountId as searchEn3_324_0_, ads0_1_.creationTime as creation4_324_0_, ads0_1_.creatorId as creatorId324_0_, ads0_1_.modificationTime as modifica6_324_0_, ads0_1_.synchTime as synchTime324_0_, ads0_1_.modifierId as modifierId324_0_, ads0_1_.deletionStatusId as deletion9_324_0_, ads0_1_.deleterId as deleterId324_0_, ads0_1_.pushError as pushError324_0_, ads0_.seId as seId418_0_, ads0_.title as title418_0_, ads0_.description as descript4_418_0_, ads0_.displayURL as displayURL418_0_, ads0_.destinationURL as destinat6_418_0_, ads0_.originalDestinationURL as original7_418_0_, ads0_.orderId as orderId418_0_ from MSN_Advertisements ads0_ inner join GTK_Creatives ads0_1_ on ads0_.id=ads0_1_.ID where ads0_.deletionStatusId = 0 and ads0_.orderId=?
--
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
17 years
[Hibernate-JIRA] Created: (HHH-2689) HQL Query using the relationary operator "or"
by Luiz Alberto (JIRA)
HQL Query using the relationary operator "or"
---------------------------------------------
Key: HHH-2689
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2689
Project: Hibernate3
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.0.cr4
Environment: ORACLE 9I
HIBERNATE 3.2
Reporter: Luiz Alberto
Priority: Critical
*************
EXAMPLE TABLE "REQUERIMENTO" IN THE DATA BASE
ROWID | ID(PK) | LABO(FK) | GRADUACAO(FK)
---------------------------------------------------------
1 | 110 | 5302332 | NULL
2 | 120 | NULL | 4002993
3 | 130 | NULL | 5321663
4 | 140 | 3698566 | NULL
5 | 150 | 5699636 | NULL
*************
Mapping
RequerimentoVO
.getMatriculaGraduacao() --> GraduacaoVO
.getMatriculaLABO() --> LaboVO
**************
I use one query "HQL". Predicate "OR" is used of the following form.
" FROM RequerimentoVO r "
" where ( r.matriculaGraduacao.id = :codigo or r.matriculaLABO.matricula = :codigo ) "
Which is the problem? It is bug of the Hibernate? Query returns "null"
which and the problem? I am thankful
***************
Exception when:
" FROM RequerimentoVO r "
" where r.matriculaGraduacao.id = :codigo "
it returns a RequerimentoVO
or in such a way
" FROM RequerimentoVO r "
" where r.matriculaLABO.matricula = :codigo = :codigo "
it returns a RequerimentoVO
which and the problem? I am thankful
I am thankful !
--
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
17 years
[Hibernate-JIRA] Updated: (HHH-1088) IdentifierProjection does not work with composite keys
by Diego Pires Plentz (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1088?page=c... ]
Diego Pires Plentz updated HHH-1088:
------------------------------------
Priority: Major (was: Minor)
Component/s: query-criteria
> IdentifierProjection does not work with composite keys
> ------------------------------------------------------
>
> Key: HHH-1088
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1088
> Project: Hibernate3
> Issue Type: Bug
> Components: query-criteria
> Affects Versions: 3.1 rc2
> Reporter: Max Muermann
> Attachments: CompositeIdProjection.java, CriteriaLoader.java
>
>
> When working with Criteria queries, the IdentifierProjection breaks if the entity has a composite key.
> In IdentifierProjection.java:
> public String toSqlString(Criteria criteria, int position, CriteriaQuery criteriaQuery)
> throws HibernateException {
> StringBuffer buf = new StringBuffer();
> String[] cols = criteriaQuery.getIdentifierColumns(criteria);
> for ( int i=0; i<cols.length; i++ ) {
> buf.append( cols[i] )
> .append(" as y")
> .append(position + i)
> .append('_');
> }
> return buf.toString();
> }
> This method does not add commas as separators between the column names. Easily fixed by adding
> if (i<col.length-1)
> buf.append(",");
> as the last statement inside the loop.
> However, this leads to another problem:
> the type returned by IdentifierProjection.geType is the (single) type of the composite id component. The query will however return the property values of the id component without a mapping step.
--
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
17 years
[Hibernate-JIRA] Created: (ANN-662) composite id not delimited properly in the projection of a subquery
by Nick Padgett (JIRA)
composite id not delimited properly in the projection of a subquery
-------------------------------------------------------------------
Key: ANN-662
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-662
Project: Hibernate Annotations
Issue Type: Bug
Reporter: Nick Padgett
composite id not delimited properly in the projection of a subquery. This is an issue in hibernate-3.2.5.ga.
Here is my hibernate mapping file:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="localhost.entity.impl">
<class name="ParticipantImpl" table="EVENT_PARTICIPANT"
mutable="false">
<composite-id name="id" class="ParticipantId">
<key-property name="eventId" type="long" column="EVENT_ID" />
<key-property name="teamId" type="long" column="TEAM_ID" />
<key-property name="participantId" type="long"
column="PARTICIPANT_ID" />
</composite-id>
<property name="homeAway" type="string" column="HOME_VSTR_IND"
length="5" />
</class>
</hibernate-mapping>
Here is my query:
DetachedCriteria detachedCriteria;
Organization organization;
DetachedCriteria orgDetachedCriteria;
detachedCriteria = DetachedCriteria.forClass(EventImpl.class, "e");
organization = eventCriteria.getOrganization();
if (null != organization) {
orgDetachedCriteria = DetachedCriteria.forClass(
ParticipantImpl.class, "p");
orgDetachedCriteria.setProjection(Projections.id());
orgDetachedCriteria.add(Restrictions
.eqProperty("e.id", "p.eventId"));
detachedCriteria.add(Subqueries.exists(orgDetachedCriteria));
}
The subquery ends up looking like:
select this0__.EVENT_ID as y0_this0__.TEAM_ID as y1_this0__.PARTICIPANT_ID as y2_ from PUBLIC.EVENT_PARTICIPANT this0__ where this_.EVENT_ID=this0__.EVENT_ID
Notice that there are commas missing after "y0_", "y1_", and "y2_".
--
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
17 years
[Hibernate-JIRA] Commented: (HHH-1015) Incorrect SQL generated when one-to-many foreign key is in a discriminated subclass table
by Nicolas De Cubber (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1015?page=c... ]
Nicolas De Cubber commented on HHH-1015:
----------------------------------------
I had reopend this issue has a bug on HHH-2898.
Has George Daswani sais, the workaround is to use the joined-subclass. I give an example on my issue.
> Incorrect SQL generated when one-to-many foreign key is in a discriminated subclass table
> -----------------------------------------------------------------------------------------
>
> Key: HHH-1015
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1015
> Project: Hibernate3
> Issue Type: New Feature
> Components: core
> Affects Versions: 3.1 beta 2
> Environment: Hibernate versions 3.1 beta 3 and 3.0.5
> Reporter: Steven Grimm
> Priority: Minor
>
> I have the following mappings describing a hierarchy of events and a class that the events refer to:
> <hibernate-mapping package="com.xyz">
> <class name="Event" table="event" discriminator-value="-1">
> <id name="Id" type="long" column="event_id"/>
> <discriminator column="event_type_id" type="integer" />
> <subclass name="EventPayer" discriminator-value="-3">
> <join table="event_payer">
> <key column="event_id" />
> <many-to-one name="payer" column="payer_id" class="Payer" />
> </join>
> <subclass name="EventPayerCreated" discriminator-value="1" />
> </subclass>
> </class>
> <class name="Payer" table="payer">
> <id name="payerId" column="payer_id" type="java.lang.Long"/>
> <set name="eventPayers" inverse="true" cascade="save-update">
> <key column="payer_id"/>
> <one-to-many class="EventPayer"/>
> </set>
> </class>
> </hibernate-mapping>
> When I fetch the Payer.eventPayers collection, Hibernate generates this SQL:
> select eventpayer0_.payer_id as payer7_1_,
> eventpayer0_.event_id as event1_1_,
> eventpayer0_.event_id as event1_5_0_,
> eventpayer0_1_.payer_id as payer2_6_0_,
> eventpayer0_.event_type_id as event2_5_0_
> from event eventpayer0_
> inner join event_payer eventpayer0_1_
> on eventpayer0_.event_id=eventpayer0_1_.event_id
> where eventpayer0_.payer_id=?
> The problem is that there is no event.payer_id column; payer_id is in the child table, not the parent. It appears that specifying a discriminated subclass in <one-to-many> is the same as specifying the superclass, or that Hibernate is ignoring the subclass's <join> element. As far as I can tell, this leaves no way to resolve bidirectional associations where one end of the association is in a discriminated subclass, which seems like a perfectly reasonable thing to want to do.
> I also tried changing <key column="payer_id"/> to <key property-ref="payer"/> in the Payer class's <set> element, but got similar behavior in the form of a "property not found" error: Hibernate is either looking in the superclass's properties rather than the subclass's or is ignoring the list of properties in the <join> element.
--
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
17 years
[Hibernate-JIRA] Created: (HHH-2740) SAPDBDialect generates wrong boolean expressions
by Matthias Wuttke (JIRA)
SAPDBDialect generates wrong boolean expressions
------------------------------------------------
Key: HHH-2740
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2740
Project: Hibernate3
Issue Type: Bug
Components: core
Environment: SAP DB 7.6
Reporter: Matthias Wuttke
The following code fragment works for MySQL, but does not for SAP-DB / MaxDB:
bulkUpdate("UPDATE MyObject SET recent = false");
The query Hibernate generates is:
update my_object set recent=0
The MaxDB error is "Constant must be compatible with column type and length". The following query works:
update my_object set recent=false
The same problem applies to SELECT queries generated by Hibernate for use with the SAPDB / MaxDB.
The following class fixes the problem (if you set it as the dialect to use):
public class ExtSAPDBDialect extends SAPDBDialect {
@Override
public String toBooleanValueString(boolean bool) {
return Boolean.toString(bool);
}
}
To fix the bug, I think one should change SAPDBDialect.toBooleanValueString(boolean).
hbm2ddl has some more bugs when using it with MaxDB. eg. using ";" as the statement separator, choosing the wrong column type for Strings longer than 4000 chars (but these bugs are not that bad). ;-)
Best regards
Matthias
--
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
17 years