[Hibernate-JIRA] Updated: (HBX-716) Trick to help maintenance of HQL query.
by Max Rydahl Andersen (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HBX-716?page=all ]
Max Rydahl Andersen updated HBX-716:
------------------------------------
type: Patch (was: Improvement)
> Trick to help maintenance of HQL query.
> ---------------------------------------
>
> Key: HBX-716
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-716
> Project: Hibernate Tools
> Type: Patch
> Components: hbm2java
> Versions: 3.2beta6
> Reporter: Francois Jean
> Priority: Minor
> Attachments: patch.txt
>
>
> I'm just sending a modification I made to a FreeMarket template in Hibernate Tools (hbm2java) to help us maintaining our HQL.
> We are using a large database with more the 300 tables and we often do a reverse-engineering of the database to keep our Java entities in synch and sometimes we have to deal with column names change. After the reverse-engineering process, the compiler will show errors for all the getter/setter that have change name. But it will not show any errors in HQL using "old" attribute names.
> For example if we have a table "Application" with a column "Version_num", we would get a Class "Application" with an attribute "versionNum" and its own getter and setter. If the column "Version_num" change its name for "App_version_num", the new attribute name will be "appVersionNum" with its new getter/setter. And the compiler will show errors for old code using the getter "getVersionNum". But will not show any errors for HQL like: "from " +Application.class.getName() + " where versionNum = 3"
> Solution:
> We modify the generation of the entity to include a constant string for each attribute name, by using these constants the compiler can flag error in HQL. The new HQL would be:
> "from " +Application.class.getName() + " where "+ Application.VERSIONNUM + " = 3"
> For now, we always generate these constants but it could be possible to trigger the constants generation by using a parameter in the ant task when asking Hibernate Tools to generate Java entities.
> Template that was modified: PojoFields.ftl
> // Fields name constant
>
> <#foreach field in pojo.getAllPropertiesIterator()><#if pojo.getMetaAttribAsBool(field, "gen-property", true)>
> public static final String ${field.name?upper_case} = "${field.name}";
> </#if>
> </#foreach>
>
> // Fields
> <#foreach field in pojo.getAllPropertiesIterator()><#if pojo.getMetaAttribAsBool(field, "gen-property", true)> <#if pojo.hasMetaAttribute(field, "field-description")> /**
> ${pojo.getFieldJavaDoc(field, 0)}
> */
> </#if> ${pojo.getFieldModifiers(field)} ${pojo.getJavaTypeName(field, jdk5)} ${field.name}<#if pojo.hasFieldInitializor(field, jdk5)> = ${pojo.getFieldInitialization(field, jdk5)}</#if>;
> </#if>
> </#foreach>
> PS: This solution is not perfect, a better approach would be something that would also validate at compilation time the type of association. For example, the association "person.address.city" present in a HQL statement will only be validated when this HQL will be executed.
> François J.
--
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
19 years, 7 months
[Hibernate-JIRA] Closed: (HBX-420) cfg2hbm produces invalid documents w/ inheritance
by Max Rydahl Andersen (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HBX-420?page=all ]
Max Rydahl Andersen closed HBX-420:
-----------------------------------
Fix Version: 3.2beta8
Resolution: Fixed
assumed fixed due to another bug that implemented basic subclass support
> cfg2hbm produces invalid documents w/ inheritance
> -------------------------------------------------
>
> Key: HBX-420
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-420
> Project: Hibernate Tools
> Type: Improvement
> Components: reverse-engineer
> Versions: 3.2LATER
> Environment: Eclipse 3.1, co build of HibernateExt from oct 1, 2005.
> Reporter: Dennis C. Byrne
> Priority: Minor
> Fix For: 3.2beta8
> Attachments: BuyNow.hbm.xml
>
>
> Use cases w/ subclass do not work with hbm2CfgXml and cfg2hbm .
> Example, the CE model ; using ant, I want to generate a working domain model from the mapping files. The end results should be:
> 1.)hibernate.cfg.xml
> 2.) *.hbm.xml
> The configuration element is used w/ nested fileset element. The nested fileset element uses an include to scoop up all *.hbm.xml files.
> There are two ways to satisfy the last requirement. Use a <cfg2hbm> or <copy>. The first of these options will take Bid.hbm.xml, and produce two files, Bid.hbm.xml and BidNow.hbm.xml . BidNow.hbm.xml will not be valid against the DTD because there is a table attribute in a subclass element. No big deal, why do we need to generate documents we already have? So use <copy>, it's not as though we are using the annotationconfiguration element. Using copy however means that you will have to manually edit hibernate.cfg.xml, because it will be generated w/ a mapping element for both Bid.hbm.xml and BidNow.hbm.xml .
> An invalid table attribute should not be produced for generated subclass elements.
--
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
19 years, 7 months
[Hibernate-JIRA] Closed: (HBX-467) Confusing variable names for FK objects, part2
by Max Rydahl Andersen (JIRA)
[ http://opensource.atlassian.com/projects/hibernate/browse/HBX-467?page=all ]
Max Rydahl Andersen closed HBX-467:
-----------------------------------
Resolution: Won't Fix
patches welcome, but closing until that happens since every user has a diffrent wish for the generated names.
> Confusing variable names for FK objects, part2
> ----------------------------------------------
>
> Key: HBX-467
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-467
> Project: Hibernate Tools
> Type: Bug
> Components: hbm2java
> Environment: hsql, current hibernate, hibernate-tools
> Reporter: George Lindholm
> Priority: Minor
> Attachments: build.sh, build.xml, fk.pa, hibernate.cfg.xml, hibernate.reveng.xml, hsqlschema.sql
>
>
> I'm able to reproduce this issue using hsqldb and the current source from the
> repository using ant so I certain that there is no interference from other jar files.
> After having run hbm2java I get:
> // default package
> // Generated Nov 4, 2005 4:10:19 PM by Hibernate Tools 3.1.0 beta1Fri Nov 04 16:10:19 PST 2005 GNL
> import java.util.Set;
> /**
> * NcContact generated by hbm2java
> */
> public class NcContact implements java.io.Serializable {
> // Fields
> private long contactId;
> private NcOrgUnit ncOrgUnit;
> private NcContact ncContact;
> private String classificationCde;
> private String role;
> private Set ncClassifTypeTblsForGroupId;
> private Set ncContacts;
> private Set ncClassifTypeTblsForLastUpdtBy;
> the variable ncContact should be lastUpdtBy.
--
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
19 years, 7 months