From: <leg...@at...> - 2003-09-05 05:14:28
|
The following comment has been added to this issue: Author: Greg Barton Created: Fri, 5 Sep 2003 12:13 AM Body: This will be especially convenient when static imports are introduced in Java 1.5. :) --------------------------------------------------------------------- View the issue: http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-29 Here is an overview of the issue: --------------------------------------------------------------------- Key: HB-29 Summary: generation of static final String for fields Type: Improvement Status: Assigned Priority: Major Project: Hibernate2 Assignee: Max Rydahl Andersen Reporter: Max Rydahl Andersen Created: Sat, 3 May 2003 10:17 AM Updated: Sat, 10 May 2003 9:49 PM Description: generation of static final String for fields While using Hibernate, we sometimes still call some direct sql queries that return resultsets that we process afterwards. We find easier to use direct sql than Hibernate in these cases. Anyway, Hibernate could provide some help: if every field in each persistent class had a corresponding constant string, that string could be used in the sql statement. Example: Given table A_table: varchar fieldone, int fieldtwo... Something like this woudl be generated: class Atable public static final String TABLENAME="A_table" public static final String FIELDONE ="fieldone" public static final String FIELDTWO ="fieldtwo" ... And these constants can be used in the java code: String sql = "select ..." + A.FIELDONE +" = 'avalue'"... That way, when the field change in the db (as it happens very often, at least in our projects), and code is regenerated, it is easier to handle, as errors are catched at compile. We were doing that in our previous home made persistance stuff. Also, for the lazy, you get code completion to work :) The generation could be set conditionally in the xml or at command line when generating the code. It must be quite easy to add to the current generator, but maybe is not usefull for other people, I dont know. http://sourceforge.net/tracker/index.php?func=detail&aid=701428&group_id=40712&atid=428711 --------------------------------------------------------------------- JIRA INFORMATION: 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.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira |