| View previous topic :: View next topic |
| Author |
Message |
Burnyie
Joined: 04 Nov 2009 Posts: 1
|
Posted: Wed Nov 04, 2009 3:35 pm Post subject: Netbeans CRUD generator problem |
|
|
Hi all,
Currently I am making use of the Netbeans CRUD generator. However, I got a problem when using it with an Oracle database. Based on the database I succesfully generate the entity classes including the hibernate annotations, also the JSF pages and controller classes are succesfully created (great tool!).
The problem is that the id colum in the oracle database is defined with a trigger and sequence so the code generator will also generate the id field for a page where a new record can be created.
The result of this is that the user always needs to fill in an value for id before pressing the create button.
I will try to list the important parts of the generated code:
JSP page id field:
<h:inputText id="id" value="#{javaFuncties.javaFuncties.id}" title="Id" required="true" requiredMessage="The id field is required." />
JPAController create function:
public void create(JavaFuncties javaFuncties) throws PreexistingEntityException, RollbackFailureException, Exception {
EntityManager em = null;
try {
utx.begin();
em = getEntityManager();
em.persist(javaFuncties);
utx.commit();
}
The Trigger wich activates before inserting a row into the "functies" table:
create or replace TRIGGER bir_functies
BEFORE INSERT ON java_functies
FOR EACH ROW
BEGIN
SELECT wens_seq_pk.NEXTVAL INTO :NEW.id FROM dual;
END;
The trigger makes sure that any value for the id column can be inserted, so this shouldnt be the problem.
I tried a few things to fix this problem:
Removing the input field after the form is generated --> ERROR: id to load is required for loading
Removing the input field and created a hidden field with a static value:
<h:inputHidden id="id" value="99"/>
This still gives the error "id to load is required for loading"
Does anyone knows a solution for this?
Thanks for the help in advance!
PS. Note that I am a beginning programmer, so it could be something very simple  |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|
|
|