пятница, 1 марта 2019 г.

How to make SAP JPA Entity on SAP Enterprise portal for SQL Server Database

I need to create SAP JPA Entity for SAP Enterprise Portal for work with SQL Server:

1. I Create ejb module project (EJB) and Enterprise Project (EAR).
2. Right clikck on mouse on ejb project and select JPA Tools -> Generate Entities from Tables
3. On wizard click on Add connections.
4. Select SQL Server
5. Next click on New Driver Definition, select 2008 JDBC Driver, on tab JAR List delete default driver and add your driver for DB (For java 8 you need jdbc4 driver). Click OK.
6. Input connection properties and next
7. Next you have connected to DB, choose schema and select your table to generate entity.
8. Next generate Entity as usual. JPA need uniqe id field in table. If you created table with identity id, you can specify GenerationType.IDENTITY.
9. On SAP EP go to nwa -> Application Resources.
10. Create new Custom Data Source.

  • Driver name: SYSTEM_DRIVER
  • SQL Engine: Vendor SQL
  • Isolation Level: Default
  • Driver Class Name: com.microsoft.sqlserver.jdbc.SQLServerDriver
  • Database URL: jdbc:sqlserver://<host>:1433;databaseName=DB
  • User and pass.

11. In your EAR component specify your datasource from previous step:
<data-source-name>YOUR_DATASOURCE</data-source-name>.
12. Deploy