[Hibernate-JIRA] Commented: (HHH-1574) AbstractEntityPersister.getNaturalIdentifierSnapshot doesn't work with many-to-one ids
by Arjan Veenstra (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1574?page=c... ]
Arjan Veenstra commented on HHH-1574:
-------------------------------------
And it's still there in 3.2.6.ga...
This is really annoying, having bug a with a patch which has not been resolved after two years.
> AbstractEntityPersister.getNaturalIdentifierSnapshot doesn't work with many-to-one ids
> --------------------------------------------------------------------------------------
>
> Key: HHH-1574
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1574
> Project: Hibernate3
> Issue Type: Bug
> Affects Versions: 3.1.2
> Reporter: Alex Burgel
> Attachments: resolveentity.patch, resolveentity32.patch, testcase.zip
>
>
> i just upgraded from 3.0.5 to 3.1.2, and i started seeing this problem. i'm not exactly sure where the bug is here, but this is what i'm seeing:
> i have a class, Subscription, which has a natural-id of class Subscriber and Edition (excerpts of relevant mapping files below).
> when Subscription is unloaded, if i make a change, then commit the session, i see this exception:
> HibernateException: immutable natural identifier of an instance of Subscription was altered
> this gets thrown from DefaultFlushEntityEventListener.checkNaturalId() line 80.
> i traced through that method, this is what happens:
> 1. in checkNaturalId, loaded == null , so getNaturalIdSnapshot() is called
> 2. this ends up generating some sql that selects the SubscriptionId and EditionId from the Subscription row.
> 3. the sql is generated in AbstractEntityPersister.getNaturalIdentifierSnapshot(), which calls hydrate for each returned column of the natural-id,
> 4. but hydrate only returns the id, instead of the actual entity
> 5. so this array of ids (instead of entities) ends up back in DefaultFlushEntityEventListener.checkNaturalId() as 'loaded', which gets compared to 'current'
> the trouble is that 'current' contains the entities, but 'loaded' only contains the ids of those entites, so the natural-id check fails, and i get the exception.
> this only happens when 'loaded' is null in checkNaturalId().
> the javadocs for hydrate say you have to call "resolve" afterwards... this isn't being done, so maybe thats the fix. if the natural-id is not just simple properties, then resolve should also be called.
> <class name="Subscription" table="Subscriptions" batch-size="10">
> <id name="id" column="Id" type="int"><generator class="native" /></id>
> <natural-id>
> <many-to-one name="subscriber" class="Subscriber" column="SubscriberId" />
> <many-to-one name="edition" class="Edition" column="EditionId" />
> </natural-id>
> ....
> </class>
> <class name="Subscriber" table="Subscriber">
> <id name="id" column="id" type="int"><generator class="native" /></id>
> <map name="subscriptions" inverse="true" cascade="all,delete-orphan" batch-size="10">
> <key column="SubscriberId" />
> <map-key-many-to-many column="EditionId" class="Edition" />
> <one-to-many class="Subscription" />
> </map>
> </class>
--
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
16 years
[Hibernate-JIRA] Created: (ANN-551) @SQLInsert. Columns in sql comes in different order depending on the application server used
by Søren Pedersen (JIRA)
@SQLInsert. Columns in sql comes in different order depending on the application server used
--------------------------------------------------------------------------------------------
Key: ANN-551
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-551
Project: Hibernate Annotations
Type: Bug
Components: binder
Versions: 3.2.1
Environment: Hibernate-core 3.2.2, hibernate-annotations 3.2.1. WebLogic 9.2 and JBoss 4.0.5. Oracle 10.
Reporter: Søren Pedersen
Problem:
The columns in the sql you specify in SQLInsert annotation has be ordered in the same way hibernate sorts its properties when constructing the insert sql.
Example:
When WebLogic 9.2 is used the sql should look like this:
"insert into acount (name, address, country) values (?,?,?)"
But when JBoss 4.0.5 is used the sql should look like this:
"insert into acount (address, country, name) values (?,?,?)"
The above are only examples.
Consequence:
I have to have different SQLInsert's for every JEE apllication server we support, because the properties comes in different order depending on the application server used.
Suggested solution:
In the method org.hibernate.cfg.AnnotationBinder.addElementsOfAClass(List<PropertyData> elements, PropertyHolder propertyHolder, boolean isPropertyAnnotated,String propertyAccessor, final XClass annotatedClass, ExtendedMappings mappings)
This property list shown below should be sorted to make sure that the properties also come in the same order:
List<XProperty> properties = annotatedClass.getDeclaredProperties( accessType );
--
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
16 years
[Hibernate-JIRA] Created: (HHH-3215) query with hibernate id for composite keys,and positional parameters do not work
by telicki (JIRA)
query with hibernate id for composite keys,and positional parameters do not work
--------------------------------------------------------------------------------
Key: HHH-3215
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3215
Project: Hibernate3
Issue Type: Bug
Components: query-hql
Environment: hibernate3.jar, oracle db
Reporter: telicki
I'm executing this query:
Query query = sess.createQuery( "
from Car as Car
where Car.id=?");
query.setParam(0,carPK);
where id is Hibernate pk identifier, and value of ? is Object that represents composite primary key.
The following exception occures:
org.hibernate.QueryException: Expected positional parameter count: 1, actual parameters: [dataaccess.crud.hibernate.CarPk@5b35] [from Car as Car
where Car.id=?
]
at org.hibernate.impl.AbstractQueryImpl.verifyParameters(AbstractQueryImpl.java:319)
at org.hibernate.impl.AbstractQueryImpl.verifyParameters(AbstractQueryImpl.java:275)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:75)
at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:811)
at
(...)
if I change the query to
Query query = sess.createQuery( "
from Car as Car
where Car.id=:param1");
query.setParam("param1",carPK);
and use the same object as value of param1, everything is ok
--
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
16 years
[Hibernate-JIRA] Commented: (HBX-592) hbm2ddl update=true not working
by Sukirtha Joseph (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HBX-592?page=co... ]
Sukirtha Joseph commented on HBX-592:
-------------------------------------
Even I face the same issue. I do not see any updates to the schema, nor do i see DDLs generated and stored to the file.
> hbm2ddl update=true not working
> -------------------------------
>
> Key: HBX-592
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-592
> Project: Hibernate Tools
> Issue Type: Bug
> Affects Versions: 3.1.beta5
> Reporter: Dorel Vaida
>
> The problem that I am encountering is that no matter what I change into the mapping files, the hbm2ddl, update=true will not generate the update statements into the indicated SQL output file, nor export them into the DB.
> The ANT target:
> <target name="update-tables" description="Update tables">
> <tstamp>
> <format property="stamp" pattern="yyyy-MM-dd_hh-mm-ss" />
> </tstamp>
> <hibernatetool destdir="../sql">
> <classpath>
> <!-- a classpath is optional, but needed for exporters that require access to domain classes etc. -->
> <path refid="master-classpath" />
> </classpath>
> <configuration configurationfile="src/hibernate-gen.cfg.xml" />
> <!-- annotated class/packages are specified in the hibernate.cfg.xml -->
> <hbm2ddl update="true" outputfilename="rf-update_${stamp}.sql" />
> <!-- SchemaExport based on Annotations -->
> </hibernatetool>
> </target>
> Hibernate version: 3.1.1
> Tools version: HibernateTools-3.1.0.beta4
--
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
16 years
[Hibernate-JIRA] Created: (HHH-3213) Error while translating hql with ast translator
by Severyn Vital (JIRA)
Error while translating hql with ast translator
-----------------------------------------------
Key: HHH-3213
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3213
Project: Hibernate3
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.4.sp1
Reporter: Severyn Vital
AST translator mixed up my business logic bean package name with one of it's reserved words: 'by'. Classic translator works fine with this hql.
org.hibernate.hql.ast.QuerySyntaxException: unexpected token: by near line 1, column 123 [from by.subpackage.subpackage.bean.Project upperP where upperP in (select p from by.subpackage.subpackage.bean.Project p, by.subpackage.subpackage.bean.ContractorService cs where p.service=cs.serviceId and p not in (select pc.projectId from by.subpackage.subpackage.bean.ProjectContractor pc where pc.contractor=cs.contractor) and p.projectStatus=1 and cs.contractor=? and p.address.zipCode in (?,?,?,?))]
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:31)
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:24)
at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:258)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:157)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
--
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
16 years
[Hibernate-JIRA] Created: (HHH-3186) session.createQuery method stripping braces when or condition is present
by Jerry Pothen (JIRA)
session.createQuery method stripping braces when or condition is present
------------------------------------------------------------------------
Key: HHH-3186
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3186
Project: Hibernate3
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.6, 3.2.5
Environment: RAD 6.0.1.4, Hibernate 3.2.5, DB UDB 9
Reporter: Jerry Pothen
Attachments: Hibernate_Issue_2008_03_16.txt
Please note the removal of the braces separating the OR condition. I don't know if I'm doing something stupid. Any help would be greatly appreciated.
The HQL passed to the create query method is:
from QueueCustomerView where (formStatusId in (102, 103, 104, 105)) and (accountOfficer in ('U001927', 'C001739', 'U002083', 'U002209', 'C002366', 'U001878', 'U001928', 'C002076', 'U841390', 'C002355', 'C001861', 'U002195', 'C002345', 'C001762', 'C001767', 'C002364', 'C002346')) and ((responsibleBranchId = 108 and businessLineId = 100) or (responsibleBranchId = 130 and businessLineId = 104) or (responsibleBranchId = 127 and businessLineId = 112) or (responsibleBranchId = 122 and businessLineId = 112)) order by customerStatusId desc , reassessmentDate asc
The SQL query hibernate outputs to the console is:
select queuecusto0_.field1,..., queuecusto0_.field2 from kycr.vw_customer_queue queuecusto0_ where (queuecusto0_.STATUS_ID in (102 , 103 , 104 , 105)) and (queuecusto0_.ACCT_OFF_ID in ('U001927' , 'C001739' , 'U002083' , 'U002209' , 'C002366' , 'U001878' , 'U001928' , 'C002076' , 'U841390' , 'C002355' , 'C001861' , 'U002195' , 'C002345' , 'C001762' , 'C001767' , 'C002364' , 'C002346')) and (queuecusto0_.BK_BRNCH=108 and queuecusto0_.BUSNSS_LINE=100 or queuecusto0_.BK_BRNCH=130 and queuecusto0_.BUSNSS_LINE=104 or queuecusto0_.BK_BRNCH=127 and queuecusto0_.BUSNSS_LINE=112 or queuecusto0_.BK_BRNCH=122 and queuecusto0_.BUSNSS_LINE=112) order by queuecusto0_.CUST_IS_NEW desc, queuecusto0_.REASS_DT asc
--
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
16 years