Where as in WebLogic 11g JPA was not support by default, in WebLogic 12c it is the default persistency provider.JPA 2.0 is part of JAVA EE 6.
I was trying some new JAVA EE 6 features in WebLogic 12c, so here is a is a way to create a Web Application with JPA under WebLogic 12c
Some of the JAVA EE 6 specifications we’re already supported in WebLogic 11g. JPA 2.0 was one of them. Though version 1.0 was the default. 2.0 also worked.Unless an explicit <provider>…</provider> wass specified in the persistence.xml file of a deployed application, WebLogic 11g used OpenJPA/Kodo by default.
The default JPA provider setting is exposed via a new MBean: JPAMBean on the DomainMBean, and persists the configuration into the config.xml file.
Furthermore, you needed to install the patch QWG8 – Enable JPA 2.0 support on WebLogic Server.
To make it work on 11g, you had to use Oracle TopLink as the persistency provider like the image shows you in the WebLogic Admin Console
Now for 12c this is not needed anymore, TopLink will be the default JPA Provider
We will create our own JAVA EE 6 Web Application with the NetBeans 7.1 IDE.
Choose File > New Project
Select Web Application from the Java Web category. Click Next.
Type WLS12cJPA for the project name and specify the project location.
Deselect the Use Dedicated Folder option, if selected. Click Next.
Select Oracle WebLogic Server from the Server dropdown list.
Select Java EE 6 as the Java EE Version. Click Next.
Use the registered JSF 2.1 library and Select JSF 2.1 from the  dropdown list. Click Finish.
NetBeans creates the web application project and opens index.xhtml in the editor. The faces/index.xhtml acts as the default index page.In WebLogic 12c your weblogic.xml shows no reference anymore to JSF
In 11g there was a reference in your weblogic.xml:
<library-ref> <library-name>jsf</library-name> <specification-version>2.0</specification-version> <implementation-version>1.0.0.0_2-0-2</implementation-version> <exact-match>true</exact-match> </library-ref>
For now, disable the fastswap feature by setting it to false in the weblogic.xml.
Connect to a database
We will now create the database connection by using the embedded derby database.
Click on the services tab in the left pane, and expand the derby APP tables
Create the persistence unit
To have  persistence in the application you only need to create a persistence unit, specify which data source and entity manager to use, and then let the container do the work of managing entities and persistence. You create a persistence unit by defining it in persistence.xml.
Right-click the project node in the Projects window and choose Properties, and specify in the Sources category of the Properties window, Â JDK 6 as the Source/Binary Format.
– Â Choose New File and select Persistence Unit from the Persistence category. Click Next.
–  Use the suggested unit name and create a new datasource from the derby connection, jdbc/jpasample.Edit the persistence.xml to use TopLink by specifying  oracle.toplink.essentials.PersistenceProvider as the persistence provider . The IDE will add the Oracle TopLink Essentials – 2.0.1 libraries to the classpath. In current and future versions of Oracle TopLink, Oracle TopLink Essentials is replaced by EclipseLink. Where possible, you should choose to use Oracle TopLink/EclipseLink instead of Oracle TopLink Essentials.
After clicking Finish the persistence unit will be created.
Creating  Entity Classes
You will now use the Entity Classes from Database wizard to create the entity classes based on the  database.
- Choose New File
- Select Entity Classes from Database from the Persistence category. Click Next.
- In the Entity Classes from Database wizard, select jdbc/jpasample from the Data Source drop-down list and supply the password, if necessary.
- Select the Customer table from the Available Tables and click Add. Click Next.The customertable and  related tables will be placed under Selected Tables.
- Type ejb as the package for the generated classes. Click Finish.
After Finish, NetBeans creates entity classes for each of the selected tables.
You can expand the ejb source package node to view the generated entity classes.
Generating JSF Pages
In this exercise you will use a wizard to generate JSF pages based on the existing entity classes.
- Right-click the project node and choose New > Other.
- Select from Persistence JSF Pages from Entity Classes in the JavaServer Faces category . Click Next.
- Click Add All to create JSF pages for all the available entities. Click Next.
- Type web in the JSF fields. Click Finish.
When you click Finish, the IDE generates JSF 2.0 pages and controller and converter classes for the JSF pages.
Running the Project
In this exercise you will build and deploy the web application to the WebLogic Server. You will use the Run command in the IDE to build, deploy and launch the application.
Right-click the project node and choose Run.
When you click Run, building  and deploys the WAR archive to  WebLogic r and creates and registers the new JDBC datasource. The welcome page of the application (http://<weblogicHost>:7001/WLS12cJPA/) opens in your browser.
In WebLogic the application and data source are deployed
More interesting features are for example to use JPA with Coherence as L2Cache, maybe in another post.
Well well!
Try the same tutorial using a MySQL databse with InnoDB engine and having a Many2Many relationship and an identifying One2Many relationship and you will see that: The scaffolding capacities in Netbeans do not support : handling Many2Many relationships in JSF pages and Creating a child object in a OnetoMany relationship returns a weird exception (Foreign Key constraint through EclipseLink).
That makes the netbeans scaffolding using JPA for MySQL absolutely useless! That s a big petty!
I managed to develop a big project using Netbeans hopefully because the database had no Many-to-many relationship from the start. So I started with the scaffolding and extended the code progressively…….
Please try it and see by yourself!
That is done by generating JSF pages from Entity Classes, in here you specify your operations. It  creates  Facelets for CRUD capabilities (Create.xhtml, Edit.xhtml, List.xhtml, and View.xhtml)
Â
Michel
Interesting article . Can CRUD operations be invoked ?