[Hibernate-JIRA] Created: (HHH-3754) formula using table name with space does not work
by Rupesh Kumar (JIRA)
formula using table name with space does not work
-------------------------------------------------
Key: HHH-3754
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3754
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.3.1
Environment: hibernate 3.3.1, Microsoft SQLServer
Reporter: Rupesh Kumar
Usually when you have the table name with space in its name, you need to escape it while using it in the hbm file and that works. But if you have a property with formula that uses the same table, calling this code below it throws up error : org.hibernate.exception.SQLGrammarException
Query query = session.createQuery("from tablewithspace");
List list = query.list();
tablewithspace.hbm.xml
------------------------------------
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="tablewithspace" entityname="tablewithspace" table="[table with space]">
<id name="id" column="id" length="10" type="int"/>
<property name="formulacol" formula="(select count(*) from [table with space])" type="string"/>
<property name="name" column="name" length="50" type="string"/>
</class>
</hibernate-mapping>
-----------------------------------
The stackstrace 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)
Caused by: java.sql.SQLException: [Macromedia][SQLServer JDBC Driver][SQLServer]Invalid object name 'ctablewith0_.table with space'.
at macromedia.jdbc.base.BaseExceptions.createException(Unknown Source)
at macromedia.jdbc.base.BaseExceptions.getException(Unknown Source)
at macromedia.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source)
at macromedia.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
at macromedia.jdbc.sqlserver.tds.TDSRPCRequest.processReplyToken(Unknown Source)
at macromedia.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
at macromedia.jdbc.sqlserver.SQLServerImplStatement.getNextResultType(Unknown Source)
at macromedia.jdbc.base.BaseStatement.commonTransitionToState(Unknown Source)
at macromedia.jdbc.base.BaseStatement.postImplExecute(Unknown Source)
at macromedia.jdbc.base.BasePreparedStatement.postImplExecute(Unknown Source)
at macromedia.jdbc.base.BaseStatement.commonExecute(Unknown Source)
at macromedia.jdbc.base.BaseStatement.executeQueryInternal(Unknown Source)
at macromedia.jdbc.base.BasePreparedStatement.executeQuery(Unknown Source)
at macromedia.jdbc.base.BasePreparedStatementPoolable.executeQuery(Unknown Source)
at coldfusion.server.j2ee.sql.JRunPreparedStatement.executeQuery(JRunPreparedStatement.java:74)
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)
... 40 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
16 years, 10 months
[Hibernate-JIRA] Created: (HHH-3762) LockMode.UPGRADE and TABLE_PER_CLASS and PostgreSQL generates usupported SQL
by Dobes Vandermeer (JIRA)
LockMode.UPGRADE and TABLE_PER_CLASS and PostgreSQL generates usupported SQL
----------------------------------------------------------------------------
Key: HHH-3762
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3762
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.3.1
Environment: Hibernate 3.3.1.GA, PostgreSQL 8.2, Hibernate-Annotations, Hibernate-EntityManager, Glassfish v2ur2, Windows Vista 64.bit
Reporter: Dobes Vandermeer
Priority: Minor
I created a class called Job and a few subclasses such as SendEmailJob, ProcessSubscriptionsJob, and so on. I set the inheritance type to TABLE_PER_CLASS since the columns in each are quite different. However, the worker that loads and executes the jobs is the same.
The worker was trying to use a piece of code like this:
@Timeout
public void timeout(Timer timer) {
session.get(Job.class, (Long)timer.getInfo(), LockMode.UPGRADE);
}
PostgreSQL returned the following error:
org.postgresql.util.PSQLException: ERROR: SELECT FOR UPDATE/SHARE is not allowed with UNION/INTERSECT/EXCEPT
The workaround was to lock the object separately, so hibernate only tries to select .. for update from one table:
@Timeout
public void timeout(Timer timer) {
Job job = session.get(Job.class, (Long)timer.getInfo(), LockMode.NONE);
session.refresh(job, LockMode.UPGRADE); // Now there's just one table involved
}
A possible solution to this issue would be for hibernate to do this breakdown automatically when doing a get() on a TABLE_PER_CLASS superclass - i.e. it would ignore LockMode when fetching, but if LockMode is > UPGRADE it would call refresh() with that lock mode on the found object (if any) to lock it. This does introduce an extra SELECT but I can't really think of another solution for this use case.
--
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, 10 months
[Hibernate-JIRA] Created: (HHH-3758) Data model object types issue with Id and Generics
by Giovanni Azua (JIRA)
Data model object types issue with Id and Generics
--------------------------------------------------
Key: HHH-3758
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3758
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.2.6
Environment: Hibernate 3.2.6.ga, Windows XP, Maven 2.0.9, JDK 1.6.0_11
Reporter: Giovanni Azua
Wanting to have a reusable base for Identifiable data model Object types and at the same time a stronger type checking (e.g. Generic DAO implementations) I introduced the interface and Abstract class below.
The problem is that my working models as soon as I extend from AbstractIdentifyable or just implement Identifyable, my test cases break with the following:
org.perfectjpattern.jee.api.integration.dao.DaoException: org.hibernate.exception.SQLGrammarException: could not insert: [example.datamodel.Person]
I suspect this is related to some kind of Hibernate use of Reflection that can't find in the model supertypes a definition of setId that matches exactly the type it expects e.g. Long but it is a generic parameter.
regards,
Giovanni
public interface Identifyable<Id extends java.io.Serializable>
{
public Id getId();
public void setId(Id anId);
}
and base abstract reusable implementation
public abstract class AbstractIdentifyable<Id extends java.io.serializable>
implements Identifyable<Id>
{
// ... implements the reusable Identifyable methods
}
--
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, 10 months
[Hibernate-JIRA] Commented: (ANN-161) Add support for custom code-based enums in EnumType - such as mapping ISO codes to gender Enums
by Frederic Leitenberger (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/ANN-161?page=co... ]
Frederic Leitenberger commented on ANN-161:
-------------------------------------------
Hello again, please look at the patch and include it in Hibernate.
Or at least say why not ... technically i don't see any objections.
Greetings Freddy;
> Add support for custom code-based enums in EnumType - such as mapping ISO codes to gender Enums
> -----------------------------------------------------------------------------------------------
>
> Key: ANN-161
> URL: http://opensource.atlassian.com/projects/hibernate/browse/ANN-161
> Project: Hibernate Annotations
> Issue Type: Improvement
> Components: binder
> Affects Versions: 3.1beta6
> Reporter: Leonardo Quijano
> Priority: Minor
> Attachments: MappedEnum.java.patch
>
>
> Now, this could be seen as an improvement to EnumType that's specific to a business domain, but I'm thinking it could help in the general case. Right now we can map JDK enums to several database types, such as INT, VARCHAR, etc. Each of these approaches have some drawbacks, depending on the domain:
> 1) The int mapping is not very reliable through refactorings. An enum that's mapped to a "0" or "2" integer value in the database could end up mapped as a different value if a future refactoring adds an additional enum with an ordinal of 0.
> 2) The varchar mapping could use the enum name instead of its ordinal. But again, if the enum changes, the mapping gets lost and it needs manual changes. It's also heavier on the performance side.
> A useful approach for enum mappings is to use common codes to represent them in the database. That depends of course of the domain logic that's being used. A useful example is the Human sex mapping, defined in ISO code 5218:
> http://en.wikipedia.org/wiki/ISO_5218
> * 0 = not known,
> * 1 = male,
> * 2 = female,
> * 9 = not specified.
> For this to work, the Sex enum could have a property "isoCode" that specifies the mapping between the database integer code and the Java enum.
> For other domain examples additional examples could be specified.
> The EnumType could include a parameter that indicates the property to be evaluated for code-mapping, performing the translation in this way. Of course, reflection cache / byte-code generation / whatever could be specified to speed up the process.
> As always, patches are offered if you think this improvement is viable.
--
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, 10 months