[Hibernate-JIRA] Created: (HHH-2901) Repeating method declaration in interface hierarchy causes faulty method lookup in proxies
by Wouter Lievens (JIRA)
Repeating method declaration in interface hierarchy causes faulty method lookup in proxies
------------------------------------------------------------------------------------------
Key: HHH-2901
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2901
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.5
Environment: Hibernate 3.2.5
DBMS: MySQL (probably irrelevant)
Reporter: Wouter Lievens
Consider the following two interfaces
interface A
{
public abstract void b();
}
interface B extends A
{
public abstract void b();
}
Note that B repeats the definition of "b", which is perfectly legal java code.
Now consider these two classes:
abstract class AImpl implements A
{
}
public class BImpl extends AImpl implements B
{
public final void b()
{
// implementation is irrelevant
}
}
Now consider that mappings have been created where interfaces A and B are given as the "proxy" type for mapped entity types AImpl and BImpl, respectively, and that the BImpl mapping "extends" the AImpl mapping.
Now, when an object is loaded by refering to the base type (AImpl), then invocations of the method "b" will raise the following exception:
java.lang.IllegalArgumentException: object is not an instance of declaring class
A short time spent debugging suggested to me that the method that the proxy (a proxy for A, not B!) selected to delegate the call to the "wrong" method somehow, causing this error. The problem can be remedied by removing the declaration for "b" in the B interface.
So, there is a workaround: don't repeat declarations. But still I would prefer to see this issue solved.
--
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, 1 month
[Hibernate-JIRA] Created: (HBX-733) Updated DAO code generation as discussed over the email
by Alex Kalinovsky (JIRA)
Updated DAO code generation as discussed over the email
-------------------------------------------------------
Key: HBX-733
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-733
Project: Hibernate Tools
Type: Patch
Components: hbm2java, ant
Versions: 3.1alpha5
Environment: I have tested the patch on the latest version of Hibernate Tools I got from SVN 2 weeks ago.
Reporter: Alex Kalinovsky
Attachments: dao_generation.patch
This should be a complete implementation of DAO generation according to the design we have discussed over the email. I've tested this on our project so the DAOs should be good to go, but of course a more diverse testing would be needed before releasing it to public. I'm open for recommendations and suggestions, so I see this as the first draft. Below is a list of files and comments. Contact me at kalinovsky(a)yahoo.com.
src/java/org/hibernate/tool/hbm2x
DAONewExporter.java This class is coded mainly to accept additional parameters such as dao package name and provide flexible
file naming that is used by Ant task. It would not be needed if I integrate my changes into GenericExporter.
src/templates/dao
crudDao.ftl template for regeneratable CRUD interface
crudDaoImpl.ftl template for regeneratable CRUD DAO implementation
dao.ftl template for customizable DAO interface that extends CRUD interface
daoImpl.ftl template for customizable DAO implementation that extends CRUD implementation
src/templates/dao/base
dao.ftl base interface for all DAOs
queryDao.ftl base interface for all read-only entities
crudDao.ftl base interface for all editable entities
src/templates/dao/base/hibernate
abstractDao.ftl base implementation of DAO using Hibernate
abstractQueryDao.ftl base implementation of DAO for read-only entities using Hibernate
abstractCrudDao.ftl base implementation of DAO for editable entities using Hibernate
src/testsupport
codegen.properties Test configuration to see DAO generation in action
codegen-build.xml Test build file that generates DAOs for Author and Article and compiles generated code
--
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, 1 month
[Hibernate-JIRA] Created: (HHH-2833) NullPointerException in insert-select query
by John Mazzitelli (JIRA)
NullPointerException in insert-select query
-------------------------------------------
Key: HHH-2833
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2833
Project: Hibernate3
Issue Type: Bug
Components: query-hql
Affects Versions: 3.2.3
Reporter: John Mazzitelli
I'm getting the following NPE when I convert a valid SELECT query into an INSERT SELECT query.
Here's the stack:
==================================================
Caused by: java.lang.NullPointerException
at org.hibernate.hql.ast.HqlSqlWalker.createFromJoinElement(HqlSqlWalker.java:310)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.joinElement(HqlSqlBaseWalker.java:3275)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3067)
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.insertStatement(HqlSqlBaseWalker.java:482)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:253)
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)
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)
at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:92)
at org.jboss.ejb3.entity.TransactionScopedEntityManager.createQuery(TransactionScopedEntityManager.java:127)
at org.jboss.on.domain.util.PersistenceUtility.createInsertSelectQuery(PersistenceUtility.java:225)
at org.jboss.on.server.measurement.MeasurementBaselineManagerBean.calculateAutoBaselines(MeasurementBaselineManagerBean.java:80)
... 60 more
==================================================
I first start out with this valid SELECT query (I can run this in the Hibernate Tools in Eclipse - it works and returns valid data as expected):
----------
SELECT
min(d.min) AS baselineMin,
max(d.max) AS baselineMax,
avg(d.value) AS baselineMean,
CURRENT_TIMESTAMP AS computeTime,
d.id.scheduleId AS scheduleId
FROM
MeasurementDataNumeric1H d
JOIN
d.schedule s
LEFT JOIN
s.baseline b
WHERE
b.id IS NULL
AND d.id.timestamp BETWEEN :startTime AND :endTime
GROUP BY
d.id.scheduleId
HAVING
d.id.scheduleId IN (
SELECT
d1.id.scheduleId
FROM
MeasurementDataNumeric1H d1
WHERE
d1.id.timestamp <= :startTime
)
----------
Here is what the Hibernate Tools Dynamic SQL Preview view shows me is the actual, generated SQL:
----------
select
min(measuremen0_.minvalue) as col_0_0_,
max(measuremen0_.maxvalue) as col_1_0_,
avg(measuremen0_.value) as col_2_0_,
CURRENT_TIMESTAMP as col_3_0_,
measuremen0_.SCHEDULE_ID as col_4_0_
from
public.ON_MEASUREMENT_DATA_NUM_1H measuremen0_
inner join
public.ON_MEASUREMENT_SCHEDULE measuremen1_
on measuremen0_.SCHEDULE_ID=measuremen1_.id
left outer join
public.ON_MEASUREMENT_BASELINE measuremen2_
on measuremen1_.id=measuremen2_.SCHEDULE_ID
where
(
measuremen2_.id is null
)
and (
measuremen0_.TIME_STAMP between ? and ?
)
group by
measuremen0_.SCHEDULE_ID
having
measuremen0_.SCHEDULE_ID in (
select
measuremen3_.SCHEDULE_ID
from
public.ON_MEASUREMENT_DATA_NUM_1H measuremen3_
where
measuremen3_.TIME_STAMP<=?
)
----------
Now that I can see this works, I simply add this line to the beginning of that SELECT query:
----------
INSERT INTO MeasurementBaseline (baselineMin,baselineMax,baselineMean,computeTime,scheduleId)
----------
Here is what the Hibernate Tools Dynamic SQL Preview view shows me is the actual, generated SQL:
----------
insert
into
public.ON_MEASUREMENT_BASELINE
( id, BL_MIN, BL_MAX, BL_MEAN, BL_COMPUTE_TIME, SCHEDULE_ID )
select
nextval ('public.ON_MEASUREMENT_BASELINE_ID_SEQ'),
min(measuremen0_.minvalue) as col_0_0_,
max(measuremen0_.maxvalue) as col_1_0_,
avg(measuremen0_.value) as col_2_0_,
CURRENT_TIMESTAMP as col_3_0_,
measuremen0_.SCHEDULE_ID as col_4_0_
from
public.ON_MEASUREMENT_DATA_NUM_1H measuremen0_
inner join
public.ON_MEASUREMENT_SCHEDULE measuremen1_
on measuremen0_.SCHEDULE_ID=measuremen1_.id
left outer join
public.ON_MEASUREMENT_BASELINE measuremen2_
on measuremen1_.id=measuremen2_.SCHEDULE_ID
where
(
measuremen2_.id is null
)
and (
measuremen0_.TIME_STAMP between ? and ?
)
group by
measuremen0_.SCHEDULE_ID
having
measuremen0_.SCHEDULE_ID in (
select
measuremen3_.SCHEDULE_ID
from
public.ON_MEASUREMENT_DATA_NUM_1H measuremen3_
where
measuremen3_.TIME_STAMP<=?
)
----------
If I were to pass in the HQL (the INSERT INTO...SELECT) via:
entityManager.createQuery("INSERT INTO...SELECT...and the rest...")
I get the NPE.
--
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, 1 month
[Hibernate-JIRA] Created: (HHH-2799) Default Scale value doesn't right
by Bliznets Roman (JIRA)
Default Scale value doesn't right
---------------------------------
Key: HHH-2799
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2799
Project: Hibernate3
Issue Type: Bug
Affects Versions: 3.2.0.ga
Environment: Name and version of the database you are using:MySQL 5.0.37
Reporter: Bliznets Roman
In my Mapping documents:
...
<property name="goodsNumeric" lazy="false" insert="true" update="true" not-null="false" unique="false" type="java.math.BigInteger">
<column not-null="false" unique="false" name="`goodsnumeric`" precision="5"/>
</property>
...
>From MySQL documentation
In standard SQL, the syntax DECIMAL(M) is equivalent to DECIMAL(M,0).
But In log and in database scale=2, it's have to be exactly 0.
Debug level Hibernate log excerpt:
12484 [main] DEBUG org.hibernate.tool.hbm2ddl.SchemaUpdate - create table `goodsitembasetype` (e_id bigint not null auto_increment, e_version integer not null, `goodsnumeric` numeric(5,2), `grossweightquantity` numeric(19,6), `netweightquantity` numeric(19,6), `invoicedcost` numeric(16,2), `customscost` numeric(16,2), `statisticalcost` numeric(16,2), primary key (e_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, 2 months
[Hibernate-JIRA] Created: (HHH-2444) discriminator type="integer" blows up
by Mark Grand (JIRA)
discriminator type="integer" blows up
-------------------------------------
Key: HHH-2444
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2444
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.2
Environment: Hibernate 3.2.2, Postgresql 8.2
Reporter: Mark Grand
Attachments: z.cfg.xml, z.hbm.xml
If the type of discriminator is integer, SessionFactoryImpl.<init> blows up with
org.hibernate.MappingException: Could not format discriminator value to SQL string
...
Caused by: java.lang.NumberFormatException: For input string: "com.hytaps.dataDictionary.FieldDescription"
Here is the full log:
[main] INFO com.hytaps.main.Z - Entering main method.
[main] INFO com.hytaps.recordManager.HibernateSessionFactory - Creating hibernate session factory.
[main] INFO org.hibernate.cfg.Environment - Hibernate 3.2.2
[main] INFO org.hibernate.cfg.Environment - hibernate.properties not found
[main] INFO org.hibernate.cfg.Environment - Bytecode provider name : cglib
[main] INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
[main] INFO org.hibernate.cfg.Configuration - configuring from resource: /z.cfg.xml
[main] INFO org.hibernate.cfg.Configuration - Configuration resource: /z.cfg.xml
[main] INFO org.hibernate.cfg.Configuration - Reading mappings from resource : com/hytaps/dataDictionary/z.hbm.xml
[main] INFO org.hibernate.cfg.HbmBinder - Mapping class: com.hytaps.dataDictionary.FieldDescription -> field_description
[main] INFO org.hibernate.cfg.HbmBinder - Mapping subclass: com.hytaps.dataDictionary.TimeFieldDescription -> field_description
[main] INFO org.hibernate.cfg.HbmBinder - Mapping class join: com.hytaps.dataDictionary.TimeFieldDescription -> time_field_description
[main] INFO org.hibernate.cfg.HbmBinder - Mapping subclass: com.hytaps.dataDictionary.ColorFieldDescription -> field_description
[main] INFO org.hibernate.cfg.HbmBinder - Mapping class join: com.hytaps.dataDictionary.ColorFieldDescription -> color_field_description
[main] INFO org.hibernate.cfg.Configuration - Configured SessionFactory: null
[main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Using Hibernate built-in connection pool (not for production use!)
[main] INFO org.hibernate.connection.DriverManagerConnectionProvider - Hibernate connection pool size: 20
[main] INFO org.hibernate.connection.DriverManagerConnectionProvider - autocommit mode: false
[main] INFO org.hibernate.connection.DriverManagerConnectionProvider - using driver: org.postgresql.Driver at URL: jdbc:postgresql://127.0.0.1:5432/hytaps_db
[main] INFO org.hibernate.connection.DriverManagerConnectionProvider - connection properties: {user=hytaps, password=****}
[main] INFO org.hibernate.cfg.SettingsFactory - RDBMS: PostgreSQL, version: 8.2.0
[main] INFO org.hibernate.cfg.SettingsFactory - JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 8.2 JDBC3 with SSL (build 504)
[main] INFO org.hibernate.dialect.Dialect - Using dialect: org.hibernate.dialect.PostgreSQLDialect
[main] INFO org.hibernate.transaction.TransactionFactoryFactory - Using default transaction strategy (direct JDBC transactions)
[main] INFO org.hibernate.transaction.TransactionManagerLookupFactory - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
[main] INFO org.hibernate.cfg.SettingsFactory - Automatic flush during beforeCompletion(): disabled
[main] INFO org.hibernate.cfg.SettingsFactory - Automatic session close at end of transaction: disabled
[main] INFO org.hibernate.cfg.SettingsFactory - JDBC batch size: 15
[main] INFO org.hibernate.cfg.SettingsFactory - JDBC batch updates for versioned data: disabled
[main] INFO org.hibernate.cfg.SettingsFactory - Scrollable result sets: enabled
[main] INFO org.hibernate.cfg.SettingsFactory - JDBC3 getGeneratedKeys(): disabled
[main] INFO org.hibernate.cfg.SettingsFactory - Connection release mode: auto
[main] INFO org.hibernate.cfg.SettingsFactory - Default batch fetch size: 1
[main] INFO org.hibernate.cfg.SettingsFactory - Generate SQL with comments: disabled
[main] INFO org.hibernate.cfg.SettingsFactory - Order SQL updates by primary key: disabled
[main] INFO org.hibernate.cfg.SettingsFactory - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
[main] INFO org.hibernate.hql.ast.ASTQueryTranslatorFactory - Using ASTQueryTranslatorFactory
[main] INFO org.hibernate.cfg.SettingsFactory - Query language substitutions: {}
[main] INFO org.hibernate.cfg.SettingsFactory - JPA-QL strict compliance: disabled
[main] INFO org.hibernate.cfg.SettingsFactory - Second-level cache: enabled
[main] INFO org.hibernate.cfg.SettingsFactory - Query cache: disabled
[main] INFO org.hibernate.cfg.SettingsFactory - Cache provider: org.hibernate.cache.NoCacheProvider
[main] INFO org.hibernate.cfg.SettingsFactory - Optimize cache for minimal puts: disabled
[main] INFO org.hibernate.cfg.SettingsFactory - Structured second-level cache entries: disabled
[main] INFO org.hibernate.cfg.SettingsFactory - Statistics: disabled
[main] INFO org.hibernate.cfg.SettingsFactory - Deleted entity synthetic identifier rollback: disabled
[main] INFO org.hibernate.cfg.SettingsFactory - Default entity-mode: pojo
[main] INFO org.hibernate.cfg.SettingsFactory - Named query checking : enabled
[main] INFO org.hibernate.impl.SessionFactoryImpl - building session factory
[main] FATAL com.hytaps.main.Z - An exception is being thrown out of HytapsInstaller.main()
org.hibernate.MappingException: Could not format discriminator value to SQL string
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:307)
at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
at com.hytaps.recordManager.HibernateSessionFactory.rebuildSessionFactory(HibernateSessionFactory.java:81)
at com.hytaps.recordManager.HibernateSessionFactory.createSession(HibernateSessionFactory.java:61)
at com.hytaps.main.Z.main(Z.java:49)
Caused by: java.lang.NumberFormatException: For input string: "com.hytaps.dataDictionary.FieldDescription"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.<init>(Unknown Source)
at org.hibernate.type.IntegerType.stringToObject(IntegerType.java:55)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:300)
... 6 more
[main] INFO com.hytaps.main.Z - Exiting main method
--
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, 2 months
[Hibernate-JIRA] Created: (HHH-2432) Collection Mapping via "property-ref" on non-pk-column crashes
by Stefan Krinkel (JIRA)
Collection Mapping via "property-ref" on non-pk-column crashes
--------------------------------------------------------------
Key: HHH-2432
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2432
Project: Hibernate3
Type: Bug
Components: core
Environment: 3.2.2, Sybase DB
Reporter: Stefan Krinkel
Hi,
when using the following example, Hibernate attempts to pull a "getTownId()" on an Integer!
2 Tables, Village and Councillor. Village has a comp. ID (TownId, VillageId), Councillor uses
just the TownId-Part. To accomplish that, TOWN_ID is mapped twice (first in comp.key, second
as "townCode"), to be able to do a 'property-ref'.
When doing an ordinary "village.getCouncillors()" there's an IllegalArgumentException which
roots to BasicPropertyAccessor.java:145
public Object get(Object target) throws HibernateException {
try {
return method.invoke(target, null);
}
Here target is (Integer) townId and method is "VillageId.getTownId".
<id name="id" type="integer">
<column name="COUNCILLOR_ID" />
<generator class="identity"/>
</id>
<property name="TOWN" type="integer" >
<column name="TOWN_ID" not-null="true" />
</property>
==============================================
<composite-id name="VillageId" class="Table1Id">
<key-property name="townId" type="integer">
<column name="TOWN_ID" />
</key-property>
<key-property name="villageId" type="integer">
<column name="VILLAGE_ID" />
</key-property>
</composite-id>
<property name="townCode" type="integer" insert="false" update="false">
<column name="TOWN_ID" />
</property>
<bag name="councillors" outer-join="false" inverse="false" >
<key property-ref="townCode">
<column name="TOWN_ID" not-null="true" />
</key>
<one-to-many class="COUNCILLOR" />
</bag>
Needless to say, it's a legacy database, so wildly changing tables is out of question for me, it has to
work with hibernate.
Thanks
--
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, 2 months