[
http://jira.jboss.com/jira/browse/JBSEAM-2179?page=comments#action_12385026 ]
Viorel Andronic commented on JBSEAM-2179:
-----------------------------------------
All code trimmed for readability.
@Entity
@Table(name = "group", schema = "security")
public class Group implements java.io.Serializable {
@Id
@Column(name = "id", unique = true, nullable = false)
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "gen_group")
@SequenceGenerator(name = "gen_group", sequenceName =
"security.group_id_seq", allocationSize = 1)
public int getId() {
return this.id;
}
}
I have a PostgreSQL database. I don't know if the DDL is usefull because you cannot
replicate this on MySQL and this is the only way you can autoincrement an identifier when
using PostgreSQL(this is actualy generated by PostgreSQL when declaring id as serial):
CREATE TABLE "security"."group"
(
id integer NOT NULL DEFAULT
nextval('"security".group_id_seq'::regclass),
CONSTRAINT group_pkey PRIMARY KEY (id)
)
As seam-gen, or hibernate-tools doesn't know how to recognize(at least from what I
know of) the DDL above and because I didn't manage to dig deep enough into
hibernate-tools ftls, I added to seam-gen/pojo/GetPropertyAnnotation.ftl the following
lines:
<#-- To be used for "id" named columns defined as serial in PostgreSQL
-->
<#if property.equals(pojo.identifierProperty) &&
property.name.equals("id")>
@${pojo.importType("javax.persistence.GeneratedValue")}(strategy=${pojo.importType("javax.persistence.GenerationType")}.SEQUENCE,
generator="gen_${clazz.table.name}")
@${pojo.importType("javax.persistence.SequenceGenerator")}(name="gen_${clazz.table.name}",
sequenceName="${clazz.table.schema}.${clazz.table.name}_id_seq",
allocationSize=1)
</#if>
and now my entities know how to map correctly these types of DDLs(but only if the
identifier column is named id). So the generation of the entity above is done somehow
artificially.
What I believe now is the following: seam-gen uses the same information when building
xhtml pages as when building entities and isn't aware of the two lines:
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator =
"gen_group")
@SequenceGenerator(name = "gen_group", sequenceName =
"security.group_id_seq", allocationSize = 1)
that specify that id is assigned.
I don't know if this makes any sense ... but what i'm trying to say is that:
! Seam-gen should now how to recognize " id integer NOT NULL DEFAULT
nextval('"security".group_id_seq'::regclass) " as an autoincrement
column in PostgreSQL, or the generation of vieproperty, ediproperty or list should be done
according to entities not table information !
This is a major drawback in PostgreSQL because identifiers are not recognized properly.
Seam-gen created pages show non-assigned ids
--------------------------------------------
Key: JBSEAM-2179
URL:
http://jira.jboss.com/jira/browse/JBSEAM-2179
Project: JBoss Seam
Issue Type: Bug
Components: Tools
Reporter: Viorel Andronic
Assigned To: Pete Muir
Priority: Minor
Fix For: 2.0.0.GA
seam-gen intends to exclude non-assigned id's from the property edit and view pages -
seam-gen\view\editproperty.xhtml.ftl, seam-gen\view\viewproperty.xhtml.ftl etc. They are
being shown.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira