-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: reveng creates field names which are Java reserved words
PostPosted: Tue Apr 17, 2007 9:58 am 
Newbie

Joined: Tue Apr 17, 2007 5:41 am
Posts: 2
[b]Hibernate version: 3.2.3[/b]

[b]Name and version of the database you are using: MS-SQL 2000[/b]

[b]Hibernate Tools 3.1.0.beta5[/b]

I am using the reverse engineering tool to create POJO's from an existing database (schema).

Unfortunately, one of the tables names happens to be the same as a Java reserved word (i.e. Switch). The tool creates the .java code and uses the lower case 'switch' as the name of field (if the the table is referenced by another table). This causes the Java code not to compile! E.g:

[code]
/**
* ActiveEndpoint generated by hbm2java
*/
public class ActiveEndpoint implements java.io.Serializable {

// Fields

private Switch switch;

private Set<H323activeEndpoint> h323activeEndpoints = new HashSet<H323activeEndpoint>(0);
...

/**
* Switch generated by hbm2java
*/
public class Switch implements java.io.Serializable {

// Fields

private int id;
private String name;
...
[/code]

Is there any way of working around this problem. Explicitly forcing the name to something else in hibernate.reveng.xml (e.g. Switch -> CTISwitch) does not help - the field name remains the same even if the class name changes.

Should this be logged as a bug/feature request. (Ideally, the generated code should compile out of the box)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 17, 2007 10:36 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
use 3.2.0.b9 - it does java reservered words check afaik.

if that doesn't help let me know via jira ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 18, 2007 5:34 am 
Newbie

Joined: Tue Apr 17, 2007 5:41 am
Posts: 2
Sorry. Should have tried latest version first.

Have re-tested with 3.2.0.b9, but problem still persists.

Have logged bug with JIRA (HBX-932).

BUT:

Explicitly forcing the name to something else in hibernate.reveng.xml (e.g. Switch -> CTISwitch) now works OK with 3.2.0.b9.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.