on 09-25-2008 7:39 PM
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>
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
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!
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
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
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
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.