- This topic has 12 replies, 3 voices, and was last updated 12 years, 10 months ago by
DevAlternatives.
-
AuthorPosts
-
julio.salazarMemberWhen we scaffold a Spring CRUD application with MyEclipse for Spring 10.0.0 based on tables in a Oracle 11G database, the attributes are exposed with a non-standard java naming convention.
For example, an attribute named B_ESTADO is named BEstado and when you try to use this names on a spring-data project those names are not valid.
We tried to change it on the jet templates but that’s not possible , a Custom plugin might be the appropiate way to proceed ( I found a similar approach on the below thread )
https://www.genuitec.com/forums/topic/preserve-camelcase-class-names-with-sql-server/
But when I look the plugin.xml for the plugin org.skyway.integration.data.persistence I cannot find the appropiate extension to change this behavior.
Database
MyEclipse
Thanks in advance.
cconwayMemberI’m not sure I understand why you’re looking for an extension point. If I read it right, in Jay’s example, he’s using a customization project that modifies the jet templates. Is there another post that mentioned using an extension point?
julio.salazarMemberActually if you open the solution from jay he creates a class inside the plugin project and he overrides the extension point in order to modify the class name for the domain object in the scaffold wizard (I found another thread that they apply the same strategy, changing the save and return method on the service)
He explains that the modification inside the jet template is not possible for the class camelcase convention. Actually the DataField.jet is the file that is used for creating the attributes but you have to modify all the related templates.
Is there any way to accomplish these ? We cannot do the changes manually on the wizard because there are too many tables and maybe we will recreate some of then in the near future.I’m using the spring mvc scaffold on windows 7 64 bits.
Thanks.
julio.salazarMemberCindy,
This is the other thread that I was mentioned, maybe it helps to find the solution.
https://www.genuitec.com/forums/topic/how-to-adjust-jet-customization/&highlight=
Thanks
We are facing the same problem , any solutions ?
Hi myeclipse support,
We need a solution on this case, can you give us some light on it ?
cconwayMemberTo all interested, I have escalated this problem. The simple answer to this question is that what you are asking is not really supported functionality but I may be able to get a workaround for you, if you’re willing to be patient.
Thanks for your support and we will wait for the workaround.
cconwayMemberI need further clarification on this problem so we can try to solve the right problem.
The screenshot in the original post shows the Customize User Interface screen that is used to create the labels in the generated JSP pages. Is that really where the problem lies or is this a matter of the fields and methods within the generated java objects have the wrong names? The java object field names are customized on the “Database Scaffolding Options” panel, not the “Customize User Interface” panel.
The java attributes generated for a database field named B_PRIMARY_KEY won’t currently follow the java naming convention, for example: Integer BPrimaryKey; instead of Integer bPrimaryKey; but I believe those values are coming from the HIbernate Default Reverse Engineering Strategy. If someone could clarify whether the problem is in that generated JPA entity or the JSP page that would be helpful.
Cindy,
The problem relies on the DAO,VIEW and DOMAIN layers starting with the JPA Model, as you can see in the following screens you can modify the names on “Customize user interface” but that will only change the key in the [Entity],properties file under the resource folder.
Database Scaffold Options
Customize user interface
And the code is generated this way:
domain: look the attribute namespublic class CsPlan implements Serializable { private static final long serialVersionUID = 1L; @Column(name = "C_PLANES", nullable = false) @Basic(fetch = FetchType.EAGER) @Id @XmlElement Integer CPlanes; @Column(name = "D_NOMBRE", length = 40, nullable = false) @Basic(fetch = FetchType.EAGER) @XmlElement String DNombre;
DAO look the method naming convention
public interface CsPlanDAO extends JpaDao<CsPlan> { /** * JPQL Query - findCsPlanByDDescripcion * */ public Set<CsPlan> findCsPlanByDDescripcion(String DDescripcion) throws DataAccessException;
JSP look the attribute name
<tr> <td class="label" valign="top"> <fmt:message key="csplan.cplanes.title"/>: </td> <td> ${csplan.CPlanes} </td> </tr> <tr> <td class="label" valign="top"> <fmt:message key="csplan.dnombre.title"/>: </td> <td> ${csplan.DNombre} </td> </tr>
As you can see we have the issue in all the layers. Please advise.
Hi myeclipse support,
Any solutions for this thread ?
Thanks,
cconwayMemberAll,
The attached jar file contains contains the code necessary to lowercase the attribute names. Please try these steps:
1) Import the jar file into your eclipse environment using File > Import > General > Existing Projects into Workspace.
2) Create a second Web Project.
3) Select the CustomizeAttributes project as a customization project for your new Web Project using Properties > MyEclipse > Customization
4) Scaffold from your database. You’ll notice that the fields displayed in the scaffolding wizard continue to use the default naming convention, but when the code is generated, the lowercased convention used in the customization project will be used.A final note, the CustomizeAttributes project should have no compile errors on it. If you have errors in the Problems tab indicating missing dependencies, try opening the Plugin.xml file inside the CustomizeAttributes project and adjusting the versions of the dependent projects on the “Dependencies” tab.
If you have any further difficulties using the jar file, post back here and I can try to help with them.
Attachments:
You must be logged in to view attached files.Cindy,
Thanks for your support, it works excellent, I have made a few updates on the plugin versions following your suggestions , we appreciate your time on this request.
Regards,
-
AuthorPosts