-
Bug
-
Resolution: Done
-
Minor
-
1.0.2.Final
When running:
scaffold from-entity ~.domain.* --overwrite
The generated view Bean will always use an id field as a long, even if the entity uses a different type for the @Id. For instance, this code, in an Entity class called ValMealtype:
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(unique=true, nullable=false, length=20)
private String meal;
Generates, in ValMealtypeBean:
private Long id;
<-- associated gettters and setters -->
And, later in the class:
return ValMealtypeBean.this.entityManager.find(ValMealtype.class, Long.valueOf(value));
That line in particular doesn't work at all, of course, since a Long can't be parsed out of a non-numeric String. I suppose I could name my meals with hex digits . . . CAFE . . . BEEF . . . but sadly, Chicken isn't going to fly.
Basically, scaffold probably needs to look at the type of @Id in the entity and use that to set the id field type in the generated bean.
As this is reported against a non-current release, I understand it may be fixed already. In this case, a new Beta of JBDS 5 is probably in order, as that's where I'm seeing this issue.
- is related to
-
FORGE-870 Faces scaffold does not generate form fields for @Id fields not annotated with @GeneratedValue
- Closed