[Hibernate-JIRA] Created: (HHH-2018) Cannot map views in postgres unless hbm2ddl.auto is unset
by Dave E Martin (JIRA)
Cannot map views in postgres unless hbm2ddl.auto is unset
---------------------------------------------------------
Key: HHH-2018
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2018
Project: Hibernate3
Type: Bug
Versions: 3.2.0.cr2
Environment: hibernate 3.2cr2 annotations 3.2cr1 postgresql 8.1 with postgresql-8.1-404.jdbc3.jar
This is also a problem in hibernate 3.1
Reporter: Dave E Martin
Attempting to map a view with hibernate results in:
Exception in thread "main" org.hibernate.HibernateException: Missing table: monthly_block_totals_utc
Even though this exists (as a view) in the database.
making sure hbm2ddl.auto is not set allows the application to work, but at the expense of being unable to update or validate the schema (or allow the end user to control whether the schema should be updated or not).
Furthermore, there doesn't appear to be a 'none' or any documented way to set .auto to something which would be the equivalent of it not being set. (or to clear it out of the properties, and setting it to null doesn't work either).
This appears to be related to HHH-1329 and HHH-1473.
Stepping into the process reveals that postgres apparently reports views as views and not tables, causing them to be overlooked by Hibernate when its validating.
--
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, 3 months
[Hibernate-JIRA] Created: (HHH-2681) Aggregate projection aliases should not be applied to where-clause
by Dmitry Katsubo (JIRA)
Aggregate projection aliases should not be applied to where-clause
------------------------------------------------------------------
Key: HHH-2681
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2681
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.4.sp1
Reporter: Dmitry Katsubo
Priority: Minor
Please, have a look at the following expression:
Criteria criteria = session.createCriteria(ClauseStatisticsImpl.class);
criteria.setProjection(
Projections.projectionList()
.add(Projections.groupProperty("clause"), "clause")
.add(Projections.max("useDate"), "useDate"))
.add(Property.forName("useDate").eq("2007-12-12"));
criteria.addOrder(Order.desc("useDate")).setMaxResults(20).list();
The problem is that the "eq" expression is applied to groupped property. This is not correct and causes SQL exception. Aliases defined for aggregate projections, should be only allied to "group", "having" and "order" clauses.
The mapping is:
<class name="ClauseStatisticsImpl" table="stc_clause_statistics">
<cache usage="read-write"/>
<composite-id>
<key-many-to-one name="clause" column="clauseId" class="ClauseImpl"/>
<key-property name="useDate"/>
</composite-id>
</class>
The error is:
12:32.22 [ERROR] org.hibernate.util.JDBCExceptionReporter - Column not found: Y1_ in statement [select top ? this_.clauseId as y0_, max(this_.useDate) as y1_ from stc_clause_statistics this_ where this_.userId=? and y1_=? group by this_.clauseId order by y1_ desc]
Exception in thread "AWT-EventQueue-0" org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:2223)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
at org.hibernate.loader.Loader.list(Loader.java:2099)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1569)
at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
... 27 more
Caused by: java.sql.SQLException: Column not found: Y1_ in statement [select top ? this_.clauseId as y0_, max(this_.useDate) as y1_ from stc_clause_statistics this_ where this_.userId=? and y1_=? and this_.clauseId in (select this0__.id as y0_ from stc_clause this0__ where this0__.userId in (?, ?) and this0__.languageName=? and this0__.procedureName=? and this0__.phaseName=?) group by this_.clauseId order by y1_ desc]
at org.hsqldb.jdbc.jdbcUtil.throwError(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:505)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:423)
at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1547)
at org.hibernate.loader.Loader.doQuery(Loader.java:673)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.doList(Loader.java:2220)
... 34 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
17 years, 3 months
[Hibernate-JIRA] Created: (HHH-2490) ClassCastException causes a logging statement to throw another ClassCastException upon inconsistent instantiation of NullableType
by Øyvind Roth (JIRA)
ClassCastException causes a logging statement to throw another ClassCastException upon inconsistent instantiation of NullableType
---------------------------------------------------------------------------------------------------------------------------------
Key: HHH-2490
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2490
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.2
Environment: MS SQLServer
Windows 2000
Java 1.5.0_10
Reporter: Øyvind Roth
(Have me excused that I don't know well the internalities of Hibernate,
but I think that you get the point from some kind of "bird's perpective" anyhow).
My pojo is defined in my xml mapping with a column/field as follows:
...
<property name="encrypted"
type="string"
column="encrypted"
insert="true"
update="true"
not-null="true"/>
...
The corresponding POJO class is defined with two access methods:
String getEncrypted();
and
boolean isEncrypted();
The field is a String with possible values "f" or "t".
Of convenience reasons I have added a parallell method
operating on boolean. My database is designed with a CHAR(1)
for booleans. (All this because the dam... RDBMS standard doesn't
advice a consistent boolean data type, a really big blunder from
time back in System R. OT ok, but I got it out.)
When Hibernate parses my instantiated pojo, a Boolean instance is
generated. But it's "repository" is prepared with a StringType as a
consequence of my XML configuration file. During the course, the
method nullSafeSet of class NullableType is called with the value
parameter Boolean. Eventually the
"public abstract String toString(Object value) throws HibernateException;"
method is called for StringType, which is implemented with a simple typecast.
Exception received. Whether this behavior is ok or not is one discussion.
But there's a second problem to it also: When the exception is received,
NullableType tries to log the event:
...
catch ( RuntimeException re ) {
log().info( "could not bind value '" + nullSafeToString( value ) + "' to parameter: " + index + "; " + re.getMessage() );
throw re;
}
...
And the same shit happens again. So the developer does not receive the actual exception,
but the exception received from the logging statement. A strong golden rule of thumb:
A logging statement should never ever throw. This is what I would call a bug in Hibernate.
Setting the log level to ERROR will of course not solve the problem,
because the string paramater is evaluated before the log statement is ever reached.
A variant of this issue is described under: "HHH-2034"
--
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, 3 months
[Hibernate-JIRA] Created: (HHH-2648) NPE in FromClause.java
by Heiko W. Rupp (JIRA)
NPE in FromClause.java
----------------------
Key: HHH-2648
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2648
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.1
Environment: JBoss 4.2, JDK 1.5
Reporter: Heiko W. Rupp
This JPA Query
query="SELECT m " +
"FROM MeasurementDataTrait AS m " +
"WHERE m.schedule.resource.id = :resourceId" +
" AND m.schedule.definition.displayType = :displayType " +
" AND m.id.timestamp = (" +
" SELECT MAX(mdt.id.timestamp) " +
" FROM MeasurementDataTrait AS mdt" +
" WHERE m.scheduleId = mdt.scheduleId" +
" )" +
" GROUP BY m " +
" ORDER BY m.id.timestamp DESC"
Results in this NPE:
java.lang.NullPointerException
at org.hibernate.hql.ast.tree.FromClause.findIntendedAliasedFromElementBasedOnCrazyJPARequirements(FromClause.java:120)
at org.hibernate.hql.ast.tree.FromClause.getFromElement(FromClause.java:107)
at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:81)
at org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:70)
at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:255)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3056)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2945)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4049)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3528)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1762)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1690)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:776)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:577)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:228)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
When I remove the subselect, then the query gets parsed nicely.
--
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, 3 months
[Hibernate-JIRA] Created: (HBX-946) Add a general meta for all the tables in the database, see [HBX-575]
by Hashim Kubba (JIRA)
Add a general meta for all the tables in the database, see [HBX-575]
--------------------------------------------------------------------
Key: HBX-946
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-946
Project: Hibernate Tools
Issue Type: Improvement
Components: reverse-engineer
Affects Versions: 3.2beta9
Environment: using eclipse 3.2.2
JDK 1.5
hibernate tools 3.2beta9
h2 database ver 1.0
Reporter: Hashim Kubba
Priority: Minor
I'm adding meta attributes in reveng.xml (HBX-575) for customization of the resulting Java code from a reverse engineered database. yet I would really like to be able to add a general class-description to all my classes ( say @ Auther or @version ) , even better; I want all my classes to extend BasicDataObject where I can add some static final constants to use, but now I have to add that to each table
<hibernate-reverse-engineering>
<table name="FOO">
<meta attribute="extends">BasicDataObject</meta>
</table name>
<table name="BOO">
<meta attribute="extends">BasicDataObject</meta>
</table name>
...
</hibernate-reverse-engineering>
What I would like to see is something like
<hibernate-reverse-engineering>
<meta attribute="extends">BasicDataObject</meta>
</hibernate-reverse-engineering>
and that will make all my classes extend BasicDataObject; metas that can be used directly under hibernate-reverse-engineering are:
* class-description general comment for all classes
* implements implements a common interface with constants
* extends extends a common class with constants and common methods
* scope-class make all classes protected
* scope-set all sets in all classes
* scope-get all gets in all classes
A nice to have will be:
* generated-class-suffix
* generated-class-prefix
or <meta name="generated-class" suffix="suffix" prefix="prefix" />
that will allow me to control all the classes names
--
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, 3 months
[Hibernate-JIRA] Created: (HHH-2641) Collection Loading
by Frederico (JIRA)
Collection Loading
------------------
Key: HHH-2641
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2641
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.0 final
Environment: Hibernate3, Postgresql 8.1
Reporter: Frederico
Attachments: src.tar.gz
I'm not sure if this is a bug, but no one answered me in the hibernate forum, so....
I have a collection that it is not loaded, in log it seems to be ok, but when i access the collection there is no element.
<class
name="entidades.bdufop.Sistema"
table="sistema"
schema="public"
>
<id
name="codigo"
column="codigo"
type="java.lang.String"
>
<generator class="assigned">
</generator>
</id>
<property
name="descricao"
type="java.lang.String"
update="true"
insert="true"
column="descricao"
not-null="true"
/>
<property
name="disponivel"
type="java.lang.String"
update="true"
insert="true"
column="disponivel"
not-null="true"
/>
<property
name="mensagem"
type="java.lang.String"
update="true"
insert="true"
column="mensagem"
/>
<set name="aplicacoes" lazy="true" cascade="all">
<key column="cod_sistema"/>
<one-to-many class="entidades.bdufop.Aplicacao"/>
</set>
</class>
<class
name="entidades.bdufop.Aplicacao"
table="aplicacao"
schema="public"
>
<composite-id
name="id"
class="entidades.bdufop.Aplicacao_pk"
>
<key-property
name="codigo_sistema"
type="java.lang.String"
column="cod_sistema"
/>
<key-property
name="codigo_aplicacao"
type="java.lang.String"
column="codigo"
/>
</composite-id>
<many-to-one name="sistema"
class="entidades.bdufop.Sistema"
column="cod_sistema"
insert="false"
update="false"
unique="true"
not-null="true"/>
<property
name="descricao"
type="java.lang.String"
column="descricao"
not-null="true"
/>
<property
name="versao"
type="java.lang.String"
column="versao"
/>
<property
name="dt_versao"
type="java.util.Date"
column="dt_versao"
/>
<property
name="disponivel"
type="java.lang.String"
column="disponivel"
not-null="true"
/>
<property
name="url"
type="java.lang.String"
column="url"
/>
<property
name="mensagem"
type="java.lang.String"
column="mensagem"
/>
</class>
Log
12:21:42,060 DEBUG DefaultInitializeCollectionEventListener:41 - initializing collection [entidades.bdufop.Sistema.aplicacoes#ACESSO]
12:21:42,063 DEBUG DefaultInitializeCollectionEventListener:47 - checking second-level cache
12:21:42,067 DEBUG DefaultInitializeCollectionEventListener:59 - collection not cached
12:21:42,071 DEBUG Loader:1911 - loading collection: [entidades.bdufop.Sistema.aplicacoes#ACESSO]
12:21:42,075 DEBUG AbstractBatcher:311 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
12:21:42,079 DEBUG ConnectionManager:415 - opening JDBC connection
12:21:42,118 DEBUG SQL:346 - select aplicacoes0_.cod_sistema as cod1_1_, aplicacoes0_.codigo as codigo1_, aplicacoes0_.cod_sistema as cod1_1_0_, aplicacoes0_.codigo as codigo1_0_, aplicacoes0_.descricao as descricao1_0_, aplicacoes0_.versao as versao1_0_, aplicacoes0_.dt_versao as dt5_1_0_, aplicacoes0_.disponivel as disponivel1_0_, aplicacoes0_.url as url1_0_, aplicacoes0_.mensagem as mensagem1_0_ from public.aplicacao aplicacoes0_ where aplicacoes0_.cod_sistema=?
Hibernate: select aplicacoes0_.cod_sistema as cod1_1_, aplicacoes0_.codigo as codigo1_, aplicacoes0_.cod_sistema as cod1_1_0_, aplicacoes0_.codigo as codigo1_0_, aplicacoes0_.descricao as descricao1_0_, aplicacoes0_.versao as versao1_0_, aplicacoes0_.dt_versao as dt5_1_0_, aplicacoes0_.disponivel as disponivel1_0_, aplicacoes0_.url as url1_0_, aplicacoes0_.mensagem as mensagem1_0_ from public.aplicacao aplicacoes0_ where aplicacoes0_.cod_sistema=?
12:21:42,122 DEBUG AbstractBatcher:424 - preparing statement
12:21:42,129 DEBUG StringType:80 - binding 'ACESSO' to parameter: 1
12:21:42,144 DEBUG AbstractBatcher:327 - about to open ResultSet (open ResultSets: 0, globally: 0)
12:21:42,148 DEBUG Loader:1040 - result set contains (possibly empty) collection: [entidades.bdufop.Sistema.aplicacoes#ACESSO]
12:21:42,152 DEBUG CollectionLoadContext:84 - uninitialized collection: initializing
12:21:42,509 DEBUG Loader:682 - processing result set
12:21:42,513 DEBUG Loader:687 - result set row: 0
12:21:42,517 DEBUG StringType:122 - returning 'ACESSO ' as column: cod1_1_0_
12:21:42,542 DEBUG StringType:122 - returning 'AP.ACESSO ' as column: codigo1_0_
12:21:42,550 DEBUG Loader:1164 - result row: EntityKey[entidades.bdufop.Aplicacao#component[codigo_sistema,codigo_aplicacao]{codigo_aplicacao=AP.ACESSO , codigo_sistema=ACESSO }]
12:21:42,558 DEBUG Loader:1347 - Initializing object from ResultSet: [entidades.bdufop.Aplicacao#component[codigo_sistema,codigo_aplicacao]{codigo_aplicacao=AP.ACESSO , codigo_sistema=ACESSO }]
12:21:42,563 DEBUG AbstractEntityPersister:1860 - Hydrating entity: [entidades.bdufop.Aplicacao#component[codigo_sistema,codigo_aplicacao]{codigo_aplicacao=AP.ACESSO , codigo_sistema=ACESSO }]
12:21:42,574 DEBUG StringType:122 - returning 'ACESSO ' as column: cod1_1_0_
12:21:42,579 DEBUG StringType:122 - returning 'DESCRICAO APLICACAO ACESSO ' as column: descricao1_0_
12:21:42,586 DEBUG StringType:122 - returning ' ' as column: versao1_0_
12:21:42,592 DEBUG TimestampType:122 - returning '2008-01-01 00:00:00' as column: dt5_1_0_
12:21:42,598 DEBUG StringType:122 - returning 'S' as column: disponivel1_0_
12:21:42,602 DEBUG StringType:122 - returning '' as column: url1_0_
12:21:42,608 DEBUG StringType:122 - returning '' as column: mensagem1_0_
12:21:42,613 DEBUG StringType:122 - returning 'ACESSO ' as column: cod1_1_
12:21:42,618 DEBUG Loader:972 - found row of collection: [entidades.bdufop.Sistema.aplicacoes#ACESSO ]
12:21:42,640 DEBUG CollectionLoadContext:100 - new collection: instantiating
12:21:42,659 DEBUG StringType:122 - returning 'ACESSO ' as column: cod1_1_
12:21:42,665 DEBUG StringType:122 - returning 'AP.ACESSO ' as column: codigo1_
12:21:42,671 DEBUG DefaultLoadEventListener:153 - loading entity: [entidades.bdufop.Aplicacao#component[codigo_sistema,codigo_aplicacao]{codigo_aplicacao=AP.ACESSO , codigo_sistema=ACESSO }]
12:21:42,677 DEBUG DefaultLoadEventListener:304 - attempting to resolve: [entidades.bdufop.Aplicacao#component[codigo_sistema,codigo_aplicacao]{codigo_aplicacao=AP.ACESSO , codigo_sistema=ACESSO }]
12:21:42,687 DEBUG DefaultLoadEventListener:313 - resolved object in session cache: [entidades.bdufop.Aplicacao#component[codigo_sistema,codigo_aplicacao]{codigo_aplicacao=AP.ACESSO , codigo_sistema=ACESSO }]
12:21:42,712 DEBUG Loader:709 - done processing result set (1 rows)
12:21:42,716 DEBUG AbstractBatcher:334 - about to close ResultSet (open ResultSets: 1, globally: 1)
12:21:42,721 DEBUG AbstractBatcher:319 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
12:21:42,757 DEBUG AbstractBatcher:470 - closing statement
12:21:42,806 DEBUG ConnectionManager:398 - aggressively releasing JDBC connection
12:21:42,815 DEBUG ConnectionManager:435 - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
12:21:42,821 DEBUG Loader:839 - total objects hydrated: 1
12:21:42,829 DEBUG TwoPhaseLoad:107 - resolving associations for [entidades.bdufop.Aplicacao#component[codigo_sistema,codigo_aplicacao]{codigo_aplicacao=AP.ACESSO , codigo_sistema=ACESSO }]
12:21:42,834 DEBUG DefaultLoadEventListener:153 - loading entity: [entidades.bdufop.Sistema#ACESSO ]
12:21:42,874 DEBUG DefaultLoadEventListener:230 - creating new proxy for entity
12:21:43,422 DEBUG TwoPhaseLoad:206 - done materializing entity [entidades.bdufop.Aplicacao#component[codigo_sistema,codigo_aplicacao]{codigo_aplicacao=AP.ACESSO , codigo_sistema=ACESSO }]
12:21:43,427 DEBUG CollectionLoadContext:262 - 2 collections were found in result set for role: entidades.bdufop.Sistema.aplicacoes
12:21:43,432 DEBUG CollectionLoadContext:206 - collection fully initialized: [entidades.bdufop.Sistema.aplicacoes#ACESSO]
12:21:43,436 DEBUG CollectionLoadContext:206 - collection fully initialized: [entidades.bdufop.Sistema.aplicacoes#ACESSO ]
12:21:43,441 DEBUG CollectionLoadContext:272 - 2 collections initialized for role: entidades.bdufop.Sistema.aplicacoes
12:21:43,445 DEBUG StatefulPersistenceContext:748 - initializing non-lazy collections
12:21:43,449 DEBUG Loader:1935 - done loading collection
12:21:43,453 DEBUG DefaultInitializeCollectionEventListener:61 - collection initialized
--
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, 3 months