[EJB 3.0] - Re: Use oracle to generate the id with the orcle seqence tab
by sraick
What I do here, not very clean but it works,
I have created an annotation called Sequence and then I place it on my bean as follow
@Sequence(name="TABLE_SEQ") where table_seq is the name of my Oracle sequence.
In my persistent class, I create a new persistent bean when needed with empty properties. But I set already its id by doing this (pb is my persistent bean):
| StringBuilder sb = new StringBuilder("select ");
| Sequence seqAnnotation = persistentBeanClass.getAnnotation(Sequence.class);
| if (seqAnnotation != null)
| sb.append(seqAnnotation.name());
|
| sb.append(".nextVal from dual");
|
| Query query = entityManager.createNativeQuery(sb.toString());
| Long id = new Long(((Number) query.getSingleResult()).longValue());
| pb.setId(id);
|
So your bean has the same id generated by the Oracle sequence, before comit. Hope this helps
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4085466#4085466
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4085466
18 years, 10 months
[JBoss Seam] - Re: Wannabe-Example needs help growing up
by pete.muir@jboss.org
Then yes, make the entire Employees conversational - you want to make the link not propagate the conversation, then add a <begin-conversation /> element to the page definition in pages.xml. You might consider a nested conversation for editing an employee along with manual flush mode to make that atomic. You don't need to end the conversation - it can either timeout OR you can specify *which* conversation to join when you click the link and make it so when Employees are clicked you go back to the same conversation (workspace). To do this you need to specify the conversation id (unique across the app, perhaps Employees-). Or you can use natural conversations in Seam2.
<conversation name="EditEmployee"
| parameter-name="employeeId"
| parameter-value="#{employee.id}"/>
|
| <page conversation="EditEmployee" />
is a natural conversation - so less wiring than manually specifying ids (but still the same thing under the bonnet).
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4085463#4085463
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4085463
18 years, 10 months
[JBoss Seam] - Re: Wannabe-Example needs help growing up
by stephen.friedrich
Thanks again, Pete. Some details are clearer now. Overall we're still turning around in cycles.
An initial requirement was:
Employee list should only be refreshed when clicking on the "Employees" header.
If I don't immediately start a conversation then each single employee selection will reload the list, right?
I I do immediately start a conversation I don't know where to end it.
Also I still don't see how selecting an employee from the list can continue in the same conversation when opened in the same browser tab and can start a new conversation when opened in a new browser tab.
How does the "natural conversation id" deal with multiple tabs? I might specify a specific conversation id for editing employees. Does it get some kind of suffix when I open several employee areas in multiple tabs?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4085452#4085452
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4085452
18 years, 10 months