Bug 401575 - "Generate entities from tables" should not create @Id when extending class which declares @Id
Summary: "Generate entities from tables" should not create @Id when extending class wh...
Status: NEW
Alias: None
Product: Dali JPA Tools
Classification: WebTools
Component: JPA (show other bugs)
Version: 3.2   Edit
Hardware: Macintosh Mac OS X
: P3 enhancement (vote)
Target Milestone: Future   Edit
Assignee: Neil Hauge CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
Depends on:
Blocks:
 
Reported: 2013-02-22 17:16 EST by Paul Furbacher CLA
Modified: 2014-02-06 14:12 EST (History)
1 user (show)

See Also:


Attachments
Shell script to massage generated model files (1.53 KB, application/x-sh)
2013-03-08 13:56 EST, Paul Furbacher CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Furbacher CLA 2013-02-22 17:16:10 EST
If you define a superclass which already defines @Id and related methods, the JPA Tools "Generate Entities from Tables..." wizard should not generate @Id and related methods in the new classes.  Currently it does this:

@Entity
@Table(name="person")
public class Person extends AbstractPersistable<Long> implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@Column(unique=true, nullable=false)
	private int id;
	...

even though "AbstractPersistable" declares @Id with public accessor methods.  The code generator should be smart enough to not write this overriding @Id, etc.


Also, the code generator should give the user the option to either "import superclass package name" or "use fully qualified name for superclass".  The former  would generate an import statement, like this: 

...
import org.springframework.data.jpa.domain.AbstractPersistable;
... 
@Entity
@Table(name="person")
public class Person extends AbstractPersistable<Long> ...


In the latter alternative, the code generator would behave as it does currently.
Comment 1 Paul Furbacher CLA 2013-03-08 13:55:26 EST
In case anyone comes across this same problem while waiting for its resolution, I'm adding to this report a bash script I wrote to massage the generated files. It assumes that you are using org.springframework.data.jpa.domain.AbstractPersistable as the superclass, and cleans up the fully qualified "extends" declaration, as well.  See attachment.
Comment 2 Paul Furbacher CLA 2013-03-08 13:56:28 EST
Created attachment 228154 [details]
Shell script to massage generated model files