Hey, really love your generator keep up the great work.
On with the post; If you create entity/object with a primary key similar to another entity/object already in the database the old one is overwritten by new one.Solution:
in the AbstractController class/bean make the following changes to the persist method:
original class didn't have else if (persistAction == PersistAction.UPDATE) but had if (persistAction != PersistAction.DELETE) {
this.ejbFacade.edit(selected);
therefore if created an entity with a primary key as another entity already in the database, the new entity would overwrite already existing entity.By the way this is for version 0.13
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you anonymous. This is similar to what was described to me by another user and I think that your solution would address that issue. Maybe... Another suggestion was to create a custom PrimaryKeyValidator and on the Create.xhtml page raise a validation error. Unfortunately, I haven't had time on investigating that idea further. What do you think?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hey, really love your generator keep up the great work.
On with the post; If you create entity/object with a primary key similar to another entity/object already in the database the old one is overwritten by new one.Solution:
in the AbstractController class/bean make the following changes to the persist method:
private void persist(PersistAction persistAction, String successMessage) {
if (selected != null) {
this.setEmbeddableKeys();
try {
if (persistAction == PersistAction.CREATE) {
this.ejbFacade.create(selected);
}else if (persistAction == PersistAction.UPDATE) {
this.ejbFacade.edit(selected);
}
else {
this.ejbFacade.remove(selected);
}
....
}
original class didn't have else if (persistAction == PersistAction.UPDATE) but had if (persistAction != PersistAction.DELETE) {
this.ejbFacade.edit(selected);
therefore if created an entity with a primary key as another entity already in the database, the new entity would overwrite already existing entity.By the way this is for version 0.13
Thank you anonymous. This is similar to what was described to me by another user and I think that your solution would address that issue. Maybe... Another suggestion was to create a custom PrimaryKeyValidator and on the Create.xhtml page raise a validation error. Unfortunately, I haven't had time on investigating that idea further. What do you think?