Bug 401575

Summary: "Generate entities from tables" should not create @Id when extending class which declares @Id
Product: [WebTools] Dali JPA Tools Reporter: Paul Furbacher <pfurbacher>
Component: JPAAssignee: Neil Hauge <neil.hauge>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: neil.hauge
Version: 3.2Keywords: helpwanted
Target Milestone: Future   
Hardware: Macintosh   
OS: Mac OS X   
Whiteboard:
Attachments:
Description Flags
Shell script to massage generated model files none

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