- This topic has 18 replies, 8 voices, and was last updated 14 years, 10 months ago by
Ram.
-
AuthorPosts
-
zokedMemberHey devangv ,
that’s the solution!
So the whole problem seems not to be a MyEclipse or hibernate issue.Getting rid of single letters in between ‘_’ in database table names and remappingmadethe wholething work very well.
Appologizes for bothering and many thanks for taking care to all of you!
Great!
ramanursMemberHi zoked – It was really nice of you to add this one. I was struggling with this from past one week.
Thanks,
Ram
Nigel SchoonParticipantHi
Please confirm – have I come across the same error???
My first time following Hibernate tutorials, and I have a table in MySQL with fields such as 01_title 02_intro etc, (all are two digits underscore word).After Hibernate reverse engineering, in the file tablenameDAO.java there are countless errors:
eg
public class BookDAO extends BaseHibernateDAO {
private static final Logger log = LoggerFactory.getLogger(BookDAO.class);
//property constants
public static final String 01_TITLE = “01Title”;
public static final String 02_INTRO = “02Intro”;
etcDo I need to to change the table names and start over?
thank you
Nigel
RamMemberNigel_VS,
According to Java language,the names of variables should not start with digit,which is happening in your case.
I would recommend you to use a custom reverse engineering strategy(Refer http://www.myeclipseide.com/documentation/quickstarts/hibernate/#5-6).Steps to follow:
============
1. Add the MyEclipse Persistence Tools library to your project.- * Right click your project and select Properties.
* On the Java Build Path page, choose Add Library… on the Libraries tab.
* Choose MyEclipse Libraries and then MyEclipse Persistence Tools.
* Press Finish.2. Create a new class in your project which extends the org.hibernate.cfg.reveng.DelegatingReverseEngineeringStrategy class.
3. Define the single argument constructor and override a method of interest, for example, columnToPropertyName.
Here’s an example which prefixes all generated propertes with “ME_”
MyStrategy.java
package com.genuitec.hibernate;import org.hibernate.cfg.reveng.DelegatingReverseEngineeringStrategy;
import org.hibernate.cfg.reveng.ReverseEngineeringStrategy;
import org.hibernate.cfg.reveng.TableIdentifier;public class MyStrategy extends DelegatingReverseEngineeringStrategy {
public MyStrategy(ReverseEngineeringStrategy strategy) {
super (strategy);
}public String columnToPropertyName(TableIdentifier table, String columnName) {
return “ME_” + super.columnToPropertyName(table, columnName);
}}
Now while Reverse Engineering again on your table,you need to refer the above created class(MyStrategy.java) in “Custom rev_eng strategy” field in the 2nd wizard of Reverse Engineer .
Let me know how this works for you.
-
AuthorPosts