The case I worked out for my demo application is the following: Create a new person via the UI (using JSF and EJB3.0 as data-layer) and initiate a bpel process for the creation of the person. The bpel process will check if all business requirements were met for the person that needs to be created using Business Rules.
A human task was added to make sure the Personal Manager has approved the new person and finally an ESB was added to actually create the person.
The ESB will transform the person-object, an xml-file, to the specific format I need to be able to insert the person in my db.
During the creation of my demo-project I faced some design problems which I will explain in the following chapters:
The first part of the case was simple, create a UI using EJB 3.0 and ADF Faces using JDeveloper as my IDE.
The UI consists of a ListPersons.jspx – page that lists all existing persons of my persons-db and a link to the CreatePerson.jspx-page. In the CreatePerson.jspx page I will create a new Person and initiate the bpel process from here.
But it wasn’t as simple as I thought … to be able to initiate my bpel process using the EJB-objects I needed to prefetch the sequence-value needed for uniquely identifying the person-object, e.g. the Person.personid. This is needed because the bpel process needs all xml-tags to be filled in. If for example the personid, or firstname isn’t filled in you will get the following exception ‘unexpected null value for literal data’.
To be able to prefetch the id in my EJB i thought I could ‘eagerly fetch’ this id using an annotation in EJB 3.0, but there’s no such annotation available
What to do next … fetch the sequence value myself and populate the Person.personID with my sequence-value.
I’ve added a new method in my SessionBean that gets the sequence value from my db-sequence, this method is invoked from my custom-method ‘createPersonObject() which constitutes a valid person-object.
The custom-method to fetch the sequence-value uses the ‘createNativeQuery’-method on the EntityManager:
em.createNativeQuery(“select person_seq.nextval from dual”);
The UI now works correctly, using the createPersonObject()-method as binding-layer to go to the CreatePerson.jspx file.
Now I need to link my existing Bpel Process to this UI … coming up soon …
May 16, 2007 at 7:30 am |
Nathalie, I was wondering why you don’t use the @SequenceGenerator and @GeneratedValue annotations for this?–olaf
May 16, 2007 at 1:09 pm |
These don’t give me the possibility to use my own dbSequence. These generators are used to pre-allocate a set of sequence values, such as the way toplink works. But that’s not the functionality I want to accomplish, I want to use my native Oracle DB-sequence to set the personID when I want to create a new person. Can I accomplish this using the generators?
May 19, 2007 at 2:45 pm |
I have the same problem too.I can’t figure out how oracle toplink doesn’t allow to change this behaviour of pre-fetching sequence inside a EJB3.0 annotation or persistence file.
May 22, 2007 at 9:31 am |
hey Angelo,Did you leave your question on the forum of Oracle, the Toplink forum? Could you leave the thread-number or url to your thread so I can check it out as well?The toplink forum can be found on the following URL:http://forums.oracle.com/forums/forum.jspa?forumID=48
May 24, 2007 at 5:31 am |
EJB 3.0 Sequence generators can use Oracle DB Sequences. You have the ultimate control over the prefetching with the allocationSize attribute. Will post an similar series on my blog soon. (blogs.oracle.com/olaf)