[The Java Posse] JPA Column question
Dumb JPA question that I can't Google up the answer for... figuring someone on the Java Posse list must know :-) The DB I'm dealing with uses the _ character in just about every single column name. This then forces me to tediously use the column annotation over and over just to account for the _ char, i.e.: @Column(name=player_id) private int playerId; Is there a way to get JPA (w/ Hibernate) to automatically translate a camel case field like playerId to the db column player_id? -- You received this message because you are subscribed to the Google Groups The Java Posse group. To post to this group, send email to javapo...@googlegroups.com. To unsubscribe from this group, send email to javaposse+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.
Re: [The Java Posse] JPA Column question
theres a way to change the default naming scheme that hibernate uses to generate column and table names with a class thats called NamingStrategy (or something very similar) On Wed, May 12, 2010 at 9:04 PM, Sean sean.c.comerf...@gmail.com wrote: Dumb JPA question that I can't Google up the answer for... figuring someone on the Java Posse list must know :-) The DB I'm dealing with uses the _ character in just about every single column name. This then forces me to tediously use the column annotation over and over just to account for the _ char, i.e.: @Column(name=player_id) private int playerId; Is there a way to get JPA (w/ Hibernate) to automatically translate a camel case field like playerId to the db column player_id? -- You received this message because you are subscribed to the Google Groups The Java Posse group. To post to this group, send email to javapo...@googlegroups.com. To unsubscribe from this group, send email to javaposse+unsubscr...@googlegroups.comjavaposse%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/javaposse?hl=en. -- http://mapsdev.blogspot.com/ Marcelo Takeshi Fukushima -- You received this message because you are subscribed to the Google Groups The Java Posse group. To post to this group, send email to javapo...@googlegroups.com. To unsubscribe from this group, send email to javaposse+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.
Re: [The Java Posse] JPA Column question
If you're using Netbeans (The Only IDE You Need :), you can use the db table-to-entity reverse engineer wizard (Entity Class From Database) and change the column names to any valid field name you would like right in the wizard and it will handle the @Column annotations for you. It also handles the DDL things like max string length, etc. Now, that said, I only recommend using this feature to build Entity classes for legacy databases - and not as a primary means to generate new Entity classes. Just wanted to give you another option/reason for using Netbeans =). On Wed, May 12, 2010 at 8:04 PM, Sean sean.c.comerf...@gmail.com wrote: Dumb JPA question that I can't Google up the answer for... figuring someone on the Java Posse list must know :-) The DB I'm dealing with uses the _ character in just about every single column name. This then forces me to tediously use the column annotation over and over just to account for the _ char, i.e.: @Column(name=player_id) private int playerId; Is there a way to get JPA (w/ Hibernate) to automatically translate a camel case field like playerId to the db column player_id? -- You received this message because you are subscribed to the Google Groups The Java Posse group. To post to this group, send email to javapo...@googlegroups.com. To unsubscribe from this group, send email to javaposse+unsubscr...@googlegroups.comjavaposse%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/javaposse?hl=en. -- You received this message because you are subscribed to the Google Groups The Java Posse group. To post to this group, send email to javapo...@googlegroups.com. To unsubscribe from this group, send email to javaposse+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.