[JBoss Seam] - EntityHome.persist - Getting the generated id?
by dustismo
Hi,
I have an entity home class and I need to get the generated id (database generated) of the persisted object after calling persist (I would have thought this would be automatic?).. It always comes back as 0.
Here is my entityHome class:
| @Name("userHome")
| public class UserHome extends EntityHome<User> {
| @In
| private EntityManager entityManager;
|
| public void setUserId(Integer id) {
| setId(id);
| }
|
| public Integer getUserId() {
| return (Integer) getId();
| }
|
| @Override
| protected User createInstance() {
| User u = new User();
| return u;
| }
|
| @Override
| public String persist() {
|
| String retval = super.persist();
| User u = this.getInstance();
| System.out.println("Persisted user: " + u.getName() + " id: " +
| u.getId() + " this.id: " + this.getId());
| return retval;
| }
| }
And the entity:
| @Entity
| @Name("user")
| @Scope(SESSION)
| @Table(name = "User")
| public class User implements java.io.Serializable {
|
| // Fields
| private int id;
|
| private String name;
|
| private String password;
|
| // Constructors
|
| /** default constructor */
| public User() {
| }
|
| // Property accessors
| @Id
| @Column(name = "id", unique = true, nullable = false)
| @NotNull
| public int getId() {
| return this.id;
| }
|
| public void setId(int id) {
| this.id = id;
| }
|
| @Column(name = "name", nullable = false, length = 64)
| @NotNull
| @Length(min = 3, max = 64)
| public String getName() {
| return this.name;
| }
|
| public void setName(String name) {
| this.name = name;
| }
|
| @Column(name = "password", nullable = false, length = 16)
| @NotNull
| @Length(min = 4, max = 16)
| public String getPassword() {
| return this.password;
| }
|
| public void setPassword(String password) {
| this.password = password;
| }
| }
Many thanks,
Dustin
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4023985#4023985
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4023985
17Â years, 10Â months
[JBoss Seam] - Re: Excel support in Seam: any interest?
by fhh
anonymous wrote :
| So how about creating s:dataTable which extends h:dataTable and adds support for
| 1) Exporting to CSV,XML,Excel,PDF
| 2) Sorting
| 3) Paging
|
Well, this is definitly not the way I would go. (As a matter of fact tomahawk has done some of the stuff but last time I looked at it it was chaotic).
What I would wish is a tag lib which really produces genuine excel files - including formulas, cell types, number formats. It would be ideal if one could use an original excel file as a "template". Then one would add pivot tables and nice little graphs to the tamplate, the user could specify some filters and aggragation levels and then the pivot data would be copied to the excel file.
This would make a LOT of controllers very, very happy.
Regards
Felix
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4023979#4023979
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4023979
17Â years, 10Â months