[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-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, 1 month
[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, 1 month
[Hibernate-JIRA] Created: (HHH-2353) ClassCastException thrown in org.hibernate.hql.ast.HqlSqlWalker.resolve
by James Andrews (JIRA)
ClassCastException thrown in org.hibernate.hql.ast.HqlSqlWalker.resolve
-----------------------------------------------------------------------
Key: HHH-2353
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2353
Project: Hibernate3
Type: Bug
Versions: 3.2.1, 3.2.0.cr4
Environment: Currently Hibernate 3.2.1, MySQL 5.0.26, Tomcat 5.5.20, Java 1.5 patch 10
Reporter: James Andrews
Above error thrown when attempting to force a left join fetch in hql on a many-to-many mapping:
Using 3 tables
accountgroup
id INTEGER PRIMARY
...
accountline
id INTEGER PRIMARY
...
accountgroupmapping
id INTEGER PRIMARY
groupId INTEGER
lineId INTEGER
...
Set mapping in hbm:
<set name="lines" table="budget.grouplinemap" fetch="join" lazy="false">
<key column="groupId" not-null="true"></key>
<many-to-many class="intranet.budget.AccountLine"
column="lineId" fetch="join" lazy="false">
</many-to-many>
</set>
HQL query executed:
select group from AccountGroup group left join fetch group.lines
Result:
java.lang.ClassCastException: org.hibernate.hql.ast.tree.SqlNode
at org.hibernate.hql.ast.HqlSqlWalker.resolve(HqlSqlWalker.java:722)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.propertyRef(HqlSqlBaseWalker.java:1105)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.propertyRefLhs(HqlSqlBaseWalker.java:4920)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.propertyRef(HqlSqlBaseWalker.java:1066)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.joinElement(HqlSqlBaseWalker.java:3198)
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.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)
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)
The above works fine if I remove the left join fetch, or if I make the relationship one-to-many, but when I create a many-to-many relationship the error above occurs.
But since the above is being encoded to an AJAX frontend, and the lines fields are referenced immediately, removing the left join fetch results in N+1 selects despite the fetch="join" and lazy="false" in the .hbm descriptor.
--
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-2016) Oracle9Dialect registers last_day() function as "lastday"
by Carl Lindberg (JIRA)
Oracle9Dialect registers last_day() function as "lastday"
---------------------------------------------------------
Key: HHH-2016
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2016
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.0 alpha, 3.0 beta 1, 3.0 beta 2, 3.0 beta 3, 3.0 beta 4, 3.0 rc 1, 3.0 final, 3.0.1, 3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.1 beta 1, 3.1 beta 2, 3.1 rc 1, 3.1 rc2, 3.1 rc3, 3.1, 3.1.1, 3.1.2, 3.2.0.alpha1, 3.2.0.alpha2, 3.1.3, 3.2.0 cr1, 3.2.0.cr2, 3.2.0.cr3
Environment: Hibernate 2.x, 3.x with an Oracle database
Reporter: Carl Lindberg
Priority: Minor
Attachments: Oracle9DialectPatch.diff, Oracle9DialectPatchOption2.diff
Oracle9Dialect.java registers a "lastday" function, however the actual Oracle function is last_day() (with the underscore). This results in a SQL error if the function is used in HQL (and obviously, HQL will not accept use of "last_day").
The patch is basically:
- registerFunction( "lastday", new StandardSQLFunction("lastday", Hibernate.DATE) );
+ registerFunction( "last_day", new StandardSQLFunction("last_day", Hibernate.DATE) );
or, if support for the incorrect "lastday" usage should still be supported:
- registerFunction( "lastday", new StandardSQLFunction("lastday", Hibernate.DATE) );
+ registerFunction( "last_day", new StandardSQLFunction("last_day", Hibernate.DATE) );
+ registerFunction( "lastday", new StandardSQLFunction("last_day", Hibernate.DATE) );
Both patch options are attached.
--
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