I am reverse engineering the database table to JPA entities. I use MyEclipse IDE , and JPA persistance implemenation chosen is EclipseLink2.5.0 Kepler.
After connecting to the embedded DerbyDB, I could reverse engineer a table named Productline to generate corresponding JPA entity Productline.java and the related jpa files. I followed this tutorial - http://docs.myeclipseide.com/index.jsp?topic=%2Fcom.genuitec.myeclipse.persistence.doc%2Fhtml%2Fquickstarts%2Fjpa%2Findex.html
The Productline table has the following columns:
productline; textdescription; htmldescription
The generated Productline.java
has the below code snippet,
@Entity
@Table(name = "PRODUCTLINE", schema = "MYSCHEMA")
public class Productline implements java.io.Serializable {
// Fields
private String productline;
private String textdescription;
private String htmldescription;
Actually I need the 'textdescription' columname as 'TXTDESC' ie
@Column(name="TXTDESC")
private String textdescription;
Question :
I like to know from experienced guys,if there is any strategy/logic where either -
(a) I can change this column name during the reverse engineering process ? [I saw the usage of SessionCustomizer
, but that is for generic logic or naming convention for all tables and columns. In my case, the column name is actually looked up and varies for each table.]
(or)
(b) I can do the reverse engineering first and then any sort of extra code generation mechanism where I can specify the custom names for each of the table columns reverse engineered?
Note: I understand that we can do it programmatically line by line for each column name, but I am trying to see if this can be leveraged with the help of MyEclipse JPA reverse engineering support or any other logic/strategy, as there would be 100+schemas with 100+tables.
It's not clear what you want to do because you can't change the column name in the table by this process. You would have to alter the table in the database to do that and then use this process.
However, you can alter the property name in the generated Java class by, instead of clicking Finish in step 3, click Next, then Next again. Now expand the Productline table and select any of the columns to see the modifications you can make to what gets generated. If you click the table itself, you can change the class name that gets generated for the table.