cancel
Showing results for 
Search instead for 
Did you mean: 

create-tables-at-deploy persistent.xml not working!

Former Member
0 Kudos

Hello,

When I specify the tag create-tables-at-deploy in persistent.xml, it does nothing! So far I can only get my application to work if I have deployed the tables through NWDS java dictionary project first. Has anyone else seen this setting actually work? It is in the DTD, and it also occurs in the j2ee deploy checklist. In the checklist it says you must make sure the tables exist OR specify create-tables-at-deploy and the app server will create the tables at deploy time per the specification in persistent.xml.

Help! I am actually writing my own sap xdoclet extension which creates the persistent.xml and ejb-j2ee-engine.xml files so that I am not tied at all to NWDS. I'd like to remove this one last dependency on the "java dictionary" project and just use this tag!

Thanks, Chris Hesse

simple example persistent.xml

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE persistent-ejb-map SYSTEM "persistent.dtd">

<persistent-ejb-map>

<create-tables-at-deploy/>

<locking type="Table"/>

<db-properties>

<data-source-name>SAPJ2EDB</data-source-name>

</db-properties>

<entity-beans>

<!--

To add beans that you have deployment descriptor info for, add

a file to your XDoclet merge directory called persistence-beans.xml

that contains the <entity-bean></entity-bean> markup for those beans.

-->

<entity-bean>

<ejb-name>Employee</ejb-name>

<table-name>ERD_EMPLOYEE</table-name>

<field-map

key-type="PrimaryKey">

<field-name>globalId</field-name>

<column>

<column-name>GLOBAL_ID</column-name>

</column>

</field-map>

<field-map

key-type="NoKey">

<field-name>firstName</field-name>

<column>

<column-name>FIRST_NAME</column-name>

</column>

</field-map>

<field-map

key-type="NoKey">

<field-name>lastName</field-name>

<column>

<column-name>LAST_NAME</column-name>

</column>

</field-map>

</entity-bean>

</entity-beans>

</persistent-ejb-map>

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Chris,

For an SAP system, this functionality should typically work.

I would ask the following questions:

1, Are you sure you are not trying to override already existing database tables with the <create-tables-at-deploy> element?

2, How did you define your DataSource?

3, What database are you using? Is it the system one or it is a custom one?

For some information on your concerns, you can take a look at the following documents:

http://help.sap.com/saphelp_nw70/helpdata/en/d2/369f1dddb7ff4c96c2bacdd7aa6c87/frameset.htm

http://help.sap.com/saphelp_nw70/helpdata/en/02/c9383eac02561ee10000000a114084/frameset.htm

http://help.sap.com/saphelp_nw70/helpdata/en/bb/69da54d8aedc419d46d9ea074e4d41/frameset.htm

http://help.sap.com/saphelp_nw70/helpdata/en/ea/a418d295d4493fa51aaad026a756b3/frameset.htm

http://help.sap.com/saphelp_nw70/helpdata/en/7f/d84b25d49846819d08e1c8ba03a9cd/frameset.htm

Regards,

Yordan

Former Member
0 Kudos

Yordan,

Thanks for your response...

I have a sample EJB jar file (and source) if you or anyone else would like to see this for themselves just let me know, but to answer your questions:

1, Are you sure you are not trying to override already existing database tables with the <create-tables-at-deploy> element?

I saw that in the documentation, so i made sure I logged into the SQL CLI to verify the tables didn't exist. They didn't.

I also made sure I tried a couple of different table names to see if I mistakenly picked a "bad" name.

2, How did you define your DataSource?

This might be one of the problems, I'm not sure. I just used the default SAPJ2EDB (my sid is J2E). Do I have to create my own? Do I have to at least create my own alias? This datasource

worked fine as long as the table was already there (ERD_EMPLOYEE)

3, What database are you using? Is it the system one or it is a custom one?

This is the maxDB database which came with my install. The system one.

I haven't seen any documentation which says I MUST use my own datasource, or my own alias to the default datasource. Is this the case? Or is there something else I'm missing?

Thanks again - Chris

Former Member
0 Kudos

Hi Chris,

As the default DataSource object should exist by default, you need to register a DataSource alias that refers to the system DataSource, and then (if I am not mistaken) use this alias in the persistent.xml instead of the DataSource name. I cannot tell how your application worked without a defined DataSource (alias)...

See this document for details on the DataSource alias registration:

http://help.sap.com/saphelp_nw70/helpdata/en/ea/a418d295d4493fa51aaad026a756b3/frameset.htm

You can also check the document describing the usage of the system DataSource:

http://help.sap.com/saphelp_nw70/helpdata/en/7f/d84b25d49846819d08e1c8ba03a9cd/frameset.htm

I hope these help!

Regards,

Yordan

Former Member
0 Kudos

Well - from what I read I thought that SAP<SID>DB (which is the default datasource) also had a default alias of SAP<SID>DB, which is what my application was using. Incidentally - I created a new alias for SAPJ2EDB, of "CHRISTEST", restarted the cluster, changed my persistent.xml file to reference "CHRISTEST", and redeployed. Same situation - table was not created. Are you interested in seeing the code or a deployable version? Thank you so much for you help!

Former Member
0 Kudos

Hi Chris,

SAP<SID>DB is the default system database schema, i.e. the default user name you should use to connect to the system database.

Your alias (CHRISTEST) should refer to the default DataSource, which is ${com.sap.datasource.default} .

You can give this a try, and then post the results here.

By the way, how did you create the alias? Using Visual Administrator or deploying it with your application (via data-source-aliases.xml)?

Regards,

Yordan

Former Member
0 Kudos

Yordan,

Thank you again for your help.

I have tried both approaches after your previous post.

In visual administrator I tried creating a new alias for the default datasource, and i seperately tried creating a new datasource with a new alias, neither worked. I also tried to create the datasource by including the xml file in the ear of my application. Of course after each attempt I made sure to restart the cluster, cleaned up any prior attempts via visual administrator etc.

The data-source-aliases.xml I tried looks like this:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE data-source-aliases SYSTEM "data-source-aliases.dtd">

<data-source-aliases>

<aliases>

<data-source-name>${com.sap.datasource.default}</data-source-name>

<alias>CHRISTEST</alias>

</aliases>

</data-source-aliases>

I feel like I've read all of the documentation, and tried everything, and it simply doesn't work. Have you seen this work? Do you know why the option wouldn't be available in the editor provided in NWDS? (I had to find the DTD and manually add the <create-tables-at-deploy/> element - there was no checkbox like the other options.

Thanks again.

Chris

Former Member
0 Kudos

Hi Chris,

I tested this functionality and it did not work for me either.

I sent that issue to some colleagues who are dealing with the persistence runtime. As soon as I receive an answer, I will post it here (unless they do so themselves).

Regards,

Yordan

Former Member
0 Kudos

Yordan,

Have you heard anything else on this issue? I submitted a low priority customer message 9/26, but it looks like nothing has been done yet. Just curious if you know of any additional info.

Former Member
0 Kudos

Hi Chris,

Unfortunately, I still have no additional info about that...

As I promised, as soon as I have some, I will post it here.

Regards,

Yordan

Former Member
0 Kudos

Hi Chris,

It comes out that this feature is not working with Open SQL DataSources, but only with Native SQL or Vendor SQL ones. The reason is that the Open SQL layer does not support DDL for this version of SAP NetWeaver, and DDL is the language used for database tables creation when you specify the <create-tables-at-deploy> tag...

As you are using the default/system DataSource (means, Open SQL), you must use Java Dictionary to define your tables.

Sorry about that inconvenience.

Best regards,

Yordan

Answers (0)