[Hibernate-JIRA] Created: (HHH-3407) @TableGenerator does not increment pkColumnValue by allocationSize
by Dan Ciarniello (JIRA)
@TableGenerator does not increment pkColumnValue by allocationSize
------------------------------------------------------------------
Key: HHH-3407
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3407
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.6, 3.2.4
Environment: JBoss 4.2.3, RHEL4, JDK1.5
Reporter: Dan Ciarniello
According to the JPA, the allocationSize attribute to @TableGenerator is "The amount to increment by when allocating id numbers from the generator" but the value is actually incremented by 1 regardless of allocationSize. The id is generated properly apparently according to the formula
id = lastkeyval*allocationSize + i where 0<i<allocationSize
The problems with this algorithm are:
1. One cannot tell what the next key value range is from the key table without knowing the allocationSize (minor)
2. If the allocationSize is reduced, already existing key values will be generated (major)
3. If two applications are configured with different allocation sizes, there will be an overlap in generated values (major)
--
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
14 years, 3 months
[Hibernate-JIRA] Created: (HHH-3709) Add StartRevision/EndRevison fileds to audit tables
by jason shi (JIRA)
Add StartRevision/EndRevison fileds to audit tables
---------------------------------------------------
Key: HHH-3709
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3709
Project: Hibernate Core
Issue Type: Improvement
Components: envers
Affects Versions: 3.4
Reporter: jason shi
In Envers audit tables(eg:Person_Aud), two fields added:REV,REVTYPE
When retrieve data at special REV, a sql with subselect executed:
select a.id, a.REV, a.REVTYPE, a.name, a.surname, a.address_id
from Person_AUD a
where a.REVTYPE <> ? and a.id = ?
and a.REV = (select max(b.REV) from Person_AUD b where b.REV <= ? and a.id = b.id)
The sql performance is poor.
I suggest adding StartRevision/EndRevison fileds to the audit tables,replace the REV field.
The StartRevision equals the original REV field,EndRevision will be filledd when this record changed in next Revision.
The new query sql will like this:
select a.id, a.REV, a.REVTYPE, a.name, a.surname, a.address_id
from Person_AUD a
where a.REVTYPE <> ? and a.id = ?
and a.StartRevision<=? and a.EndRevision>?
--
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
14 years, 3 months
[Hibernate-JIRA] Created: (HHH-4769) In HQL, function ROUND always returns an Integer, it truncate the decimal part of Double number.
by Andrea Tunesi (JIRA)
In HQL, function ROUND always returns an Integer, it truncate the decimal part of Double number.
------------------------------------------------------------------------------------------------
Key: HHH-4769
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4769
Project: Hibernate Core
Issue Type: Bug
Components: core, entity-manager, query-hql
Affects Versions: 3.3.2
Environment: hibernate 3.3.2, mysql-connector-java-5.1.7, database MYSQL 5.
Reporter: Andrea Tunesi
Priority: Blocker
Running the query "select round(stTmpRiepCap.imponibile,1), round(stTmpRiepCap.ritImponibile,1) from StTmpRiepCap stTmpRiepCap", it always returns an Integer and it always truncate the decimal part of Double number ("stTmpRiepCap.imponibile" and "stTmpRiepCap.ritImponibile" are "java.lang.Double").
Example
REAL VALUE - Imponibile: 1528.57 -- Ritenuta imponibile 266.13
VALUE RETURNED USING ROUND - Imponibile: 1528 -- Ritenuta imponibile 266
--
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
14 years, 3 months
[Hibernate-JIRA] Created: (HHH-2131) SYBASE +select for update is showing deadlock because lock is not working properly
by George Thomas (JIRA)
SYBASE +select for update is showing deadlock because lock is not working properly
----------------------------------------------------------------------------------
Key: HHH-2131
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2131
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.1.3
Environment: sybaseASE 12.5.03 in solaris +hibernate3.1.3
Reporter: George Thomas
I am connecting to Sybase database from hibernate.I tried setting locks using while selecting rows
1.session.load(class,id,LOCKMODE.UPGRADE)
2.session.lock(obj,LOCKMODE.UPGRADE)
I am attaching a sample code while updating a field in table fund after selecting it.
{
Fund fund = null;
ClientCredential credential = new ClientCredential("testDatabase", fund);
org.hibernate.Session session = SessionFactoryManager.getSessionFactory(credential).getCurrentSession();
Transaction transaction = session.beginTransaction();
log.info("Run by " + Thread.currentThread().getName());
fund = (Fund) session.get(Fund.class, new Short((short)12), LockMode.UPGRADE);
fund.setLegalEntityOrgId(fund.getLegalEntityOrgId()+1);
transaction.commit();
}
my requirement was that i wanted to do a select for update.I should acquire lock on certain rows and do a matching and if concurrent request comes ,it should wait till transaction is over that is lock is released.
When I went through the hibernate code,the hibernate is making static queries in the beginning while loading session factory.Since we are appending the holdlock during execution,the sybase dialect is not appending.
As a work around I tested with native sql with holdlock but when I test concurrent request using threads its bombing.Its throwing LockAcquisitionException.( Your server command (family id #0, process id #3777) encountered a deadlock situation.).can anyone give a solution to this problem???
org.hibernate.exception.LockAcquisitionException: could not update: [com.citco.aexeo.common.dataaccess.domain.Fund#12]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:84)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2223)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2118)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2375)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:91)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:233)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:107)
at com.satyam.Testing.doTransaction(Testing.java:103)
at com.satyam.MyRunnable.run(MyRunnable.java:13)
at java.lang.Thread.run(Thread.java:568)
Caused by: com.sybase.jdbc2.jdbc.SybSQLException: Your server command (family id #0, process id #3777) encountered a deadlock situation. Please re-run your command.
at com.sybase.jdbc2.tds.Tds.processEed(Tds.java:2636)
at com.sybase.jdbc2.tds.Tds.nextResult(Tds.java:1996)
at com.sybase.jdbc2.jdbc.ResultGetter.nextResult(ResultGetter.java:69)
at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:204)
at com.sybase.jdbc2.jdbc.SybStatement.nextResult(SybStatement.java:187)
at com.sybase.jdbc2.jdbc.SybStatement.updateLoop(SybStatement.java:1642)
at com.sybase.jdbc2.jdbc.SybStatement.executeUpdate(SybStatement.java:1625)
at com.sybase.jdbc2.jdbc.SybPreparedStatement.executeUpdate(SybPreparedStatement.java:91)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:23)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2205)
... 14 more
--
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
14 years, 3 months
[Hibernate-JIRA] Created: (ANN-837) @Where clause may trigger an ambiguous column error
by Bob Harrod (JIRA)
@Where clause may trigger an ambiguous column error
---------------------------------------------------
Key: ANN-837
URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-837
Project: Hibernate Annotations
Issue Type: Bug
Components: binder
Affects Versions: 3.3.1.GA
Environment: Hibernate Core 3.3.1GA, Annotations 3.4.0GA, PostgreSQL 8.3
Reporter: Bob Harrod
Attachments: LoginUnit.java, LoginUnitUser.java, LoginUser.java
The following annotations are being used to simulate a soft delete strategy:
@Entity
@Table(name = "login_unit_user")
@SQLDelete( sql="UPDATE login_unit_user SET _is_active = 0 WHERE id = ?")
@Where(clause="_is_active <> 0")
public class LoginUnitUser extends DomainObject implements Serializable{...}
and
@Entity
@Table(name = "login_unit")
@SQLDelete( sql="UPDATE login_unit SET _is_active = 0 WHERE id = ?")
@Where(clause="_is_active <> 0")
public class LoginUnit extends DomainObject implements Serializable{...}
In the attached code, both LoginUnit and LoginUnitUser contain a system column - "_is_active". This column represents a flag which indicates whether or not the row is "active" or "deleted". When these two hibernate model objects are queried, hibernate does not properly append the table alias to this additional where clause that it uses during it's database query. The error raised is:
org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2231)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
at org.hibernate.loader.Loader.list(Loader.java:2120)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:361)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1148)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:88)
... 35 more
Caused by: org.postgresql.util.PSQLException: ERROR: column reference "_is_active" is ambiguous
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1608)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1343)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:194)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:451)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:350)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:254)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1808)
at org.hibernate.loader.Loader.doQuery(Loader.java:697)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2228)
... 43 more
An example query with the hibernate generated aliases (loginuser0_, loginunitu1_, loginunit2_) is below:
Hibernate:
select
loginuser0_.id as id21_,
loginuser0_._audit_login_user_id as column7_21_,
loginuser0_._created as column2_21_,
loginuser0_.first_name as first3_21_,
loginuser0_.last_name as last4_21_,
loginuser0_._updated as column5_21_,
loginuser0_.user_name as user6_21_
from
login_user loginuser0_,
login_unit_user loginunitu1_,
login_unit loginunit2_
where
(
_is_active <> 0
)
and (
_is_active <> 0
)
and loginuser0_.id=loginunitu1_.login_user_id
and loginunitu1_.login_unit_id=loginunit2_.id
and loginuser0_.user_name=?
and loginunit2_.id=? limit ?
--
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
14 years, 3 months
[Hibernate-JIRA] Created: (HHH-5020) java.sql.SQLException: ORA-00904: "Y6_": invalid identifier when performing search by criteria with columns aliases defined and with restriction defined
by Alexander (JIRA)
java.sql.SQLException: ORA-00904: "Y6_": invalid identifier when performing search by criteria with columns aliases defined and with restriction defined
--------------------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-5020
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5020
Project: Hibernate Core
Issue Type: Bug
Components: query-criteria
Affects Versions: 3.2.5
Environment: Oracle 10g
Reporter: Alexander
Attachments: stacktrace.JPG
The exception is occured when I performs search by criteria like this
DetachedCriteria headerCrit = DetachedCriteria.forClass(LOSHeader.class);
ProjectionList prjList = Projections.projectionList();
prjList.add(Projections.groupProperty("channelId"),"channelId");
prjList.add(Projections.groupProperty("channel"),"channel");
prjList.add(Projections.groupProperty("subCategoryId"),"subCategoryId");
prjList.add(Projections.groupProperty("subCategory"),"subCategory");
prjList.add(Projections.groupProperty("bevCategoryId"),"bevCategoryId");
prjList.add(Projections.groupProperty("bevCategory"),"bevCategory");
prjList.add(Projections.groupProperty("accessFilter"),"accessFilter");
headerCrit.setProjection(prjList);
headerCrit.add(Restrictions.like("accessFilter","%,INTERNAL;%"));
headerCrit.setResultTransformer(Transformers.aliasToBean(LOSHeader.class));
List result = pipelineDAO.loadByCriteria(headerCrit, LOSHeader.class);
Criteria string:
DetachableCriteria(CriteriaImpl(com.ko.cokechannel.los.impl.entity.LOSHeader:this[][accessFilter like %,INTERNAL;%][channelId as channelId, channel as channel, subCategoryId as subCategoryId, subCategory as subCategory, bevCategoryId as bevCategoryId, bevCategory as bevCategory, accessFilter as accessFilter]))
The is list of projections:
[channelId as channelId, channel as channel, subCategoryId as subCategoryId, subCategory as subCategory, bevCategoryId as bevCategoryId, bevCategory as bevCategory, accessFilter as accessFilter]
Method execution stack trace (also the screenshot of stack trace is attached) :
CriteriaQueryTranslator.getWhereCondition()->
String sqlString = entry.getCriterion().toSqlString( entry.getCriteria(), this );
SimpleExpression.toSqlString() ->
CriteriaQueryTranslator.getColumnsUsingProjection(criteria, propertyName); // propertyName is "accessFilter"
ProjectionList.getColumnAliases(String alias, int loc){ // alias = "accessFilter"
....
String[] result = getProjection(i).getColumnAliases(alias, loc);
if (result!=null) return result;
.....
result is: [y6_] // Restriction for accessFilter property is mathced with the value from projection aliases, so [y6_] is returned for the WHERE condition
WHERE clause sql: y6_ like ?
The final sql looks like:
select this_.CHANNEL_ID as y0_, this_.CHANNEL_NM as y1_, this_.SUB_CATEGORY_ID as y2_, this_.SUB_CATEGORY_NM as y3_, this_.BEV_CATEGORY_ID as y4_, this_.BEV_CATEGORY_NM as y5_, this_.ACCESS_FILTER as y6_ from V_LOS_LIST this_
WHERE y6_ like ? <<<<<<< ---- THIS IS WRONG -
group by this_.CHANNEL_ID, this_.CHANNEL_NM, this_.SUB_CATEGORY_ID, this_.SUB_CATEGORY_NM, this_.BEV_CATEGORY_ID, this_.BEV_CATEGORY_NM, this_.ACCESS_FILTER
I think that the cause of this issue is the same as was mentioned in http://opensource.atlassian.com/projects/hibernate/browse/HHH-2847
To easy reproduce this issue just try to search by a criteria like this:
DetachedCriteria criteria = DetachedCriteria.forClass(Entity.class);
criteria.setProjection(Projections.groupProperty("propertyA"),"propertyA");
criteria.add(Restrictions.like("propertyA", "%"));
criteria.setResultTransformer(Transformers.aliasToBean(Entity.class));
Thank you,
Alex
--
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
14 years, 4 months
[Hibernate-JIRA] Created: (HHH-2691) Insert Into Select command outputs incorrect exception
by John Aylward (JIRA)
Insert Into Select command outputs incorrect exception
------------------------------------------------------
Key: HHH-2691
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2691
Project: Hibernate3
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.4.sp1
Environment: Hibernate 3.2.4.sp1 with Annotations 3.3.0 And Validator 3.0.0
MySQL 5.0.42
Reporter: John Aylward
receive following exception:
org.hibernate.QueryException: number of select types did not match those for insert [INSERT INTO ProviderInvoiceLineItem (amount,billingAccount,circuit,description,invoice,type) SELECT pili.amount,pili.billingAccount,pili.circuit,pili.description,:newInvoice,pili.type) FROM com.cicat.bedrock.billing.model.ProviderInvoiceLineItem pili WHERE pili.invoice = :oldInvoice]
exception should be that token ')' is not excepected near "pili.type"
Should not have gotten as far as it did, should have blown up on parsing the HQL
--
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
14 years, 4 months