Pages

Thursday, July 25, 2013

JDeveloper 12.1.2 EJB & Java Service Facade Datacontrol

With JDeveloper 12c (12.1.2)  Oracle added some great updates to the ADF EJB / Java Facade Datacontrol. Oracle already added the Java Facade and Named Criteria support in its previous versions of JDeveloper but now also added the so wanted List of Values feature, just like we have in ADF BC.  

In the the next part I will show you all the new features and some LOV bugs ( not everything is working yet )

When we create an EJB DataControl you get besides Range paging also Scrollable as an Access Mode option plus you can immediately generate all the ADF Entity Metadata. 


Just like JDeveloper 11gR2 we can add a Named Criteria to the ADF entity, basically it does the same as a Named Criteria in JPA.



Create a List of Values, select the base entity field ( Selecting the relation entity field won't work, so you need to copy the field and make one of them updatable and insertable ), select the list iterator and the field with matches the field of the base entity.  


Choose the default List Type and all the attributes we want to show in the list type.


We can now use this list type in a Query Panel where we can use it to lookup an manager.




But after selecting an employee then it goes totally wrong, it keeps on looping and tries to get a particular rownum. Also displaying this List item in an ADF Table goes wrong ( it just hangs).  I tried everything from removing all JPA entity relations, adding fetching hints to the JPA named criterias and changing the range size in ADF but all didn't help much.

But it at least it works in a Form page




With this as result


EJB Methods which contains parameters are now also generated as accessor iterators instead of method actions where you need to add method iterators on it. This is a big improvement and keeps the pagedef much cleaner


Accessor iterator

With Execute with params you can pass on the method parameter.


But somehow I did not get this working, I tried the following, first in a page with a parameter form and in bound task flow where I first invoke the execute with params action.


The second part is about the Java Service Facade.  In JDeveloper 12.1.2 the Java Service Facade contains less code and it can update the entity with or without auto commit and without manually calling the merge entity method.


The Persistence unit must be one with Resource Local as Transaction type. You can also choose if you want to do an autocommit.

Next step is generating an ADF Datacontrol on this Java Service Facade



Here we also can choose for Range paging or Scrollable as Access mode.


With a Java Service Facade and an explicit commit we can now also use the rollback or commit button. Plus we don't need to call the mergeEntity method when we change a record.
This is not the case with the EJB datacontrol.

Here you can download or see my example project

2 comments:

  1. So, you are created LOV on Transient attribute DepartmentId, and mapped EmployeeId to that attr. But how to save that EmployeeId to one of bound attribute, seems like here missing another entry in the List return values, is not?

    ReplyDelete