I'm trying to create an Entity Bean using CMP 2.0 in Weblogic 7. Using
MS SQL Server 7 with the type 4 mssqlserver jdbc driver that is part
of type 4 mssqlserverweblogic.jar.
findByPrimaryKey() works fine.
It's only ejbCreate() that's failing with the exception pasted below.
I tried setting Transcation to both Required and NotSupported.
Concurrency level is Database.
I'd be very grateful if some one could help me out of this situation.
"CECLIENT1" happens to be the name of the box where ms sql server 7 is
running.
<EJB Exception in method: ejbPostCreate: java.sql.SQLException: Line
6: Incorrect syntax near ')'. Severity 15, State 1, Procedure
'CECLIENT7 null', Line 6>
java.sql.SQLException: Line 6: Incorrect syntax near ')'. Severity 15,
State 1, Procedure 'CECLIENT7 null', Line 6
at weblogic.jdbc.mssqlserver4.TdsStatement.processWarning(TdsStatement.java:1231)
at weblogic.jdbc.mssqlserver4.TdsStatement.parseMsWarning(TdsStatement.java:1142)
at weblogic.jdbc.mssqlserver4.TdsStatement.getMoreResults(TdsStatement.java:800)
at weblogic.jdbc.mssqlserver4.TdsStatement.execute(TdsStatement.java:216)
at weblogic.jdbc.mssqlserver4.TdsStatement.executeUpdate(TdsStatement.java:99)
at weblogic.jdbc.mssqlserver4.TdsStatement.executeUpdate(TdsStatement.java:1518)
at weblogic.jdbc.pool.Statement.executeUpdate(Statement.java:294)
at weblogic.jdbc.rmi.internal.PreparedStatementImpl.executeUpdate(PreparedStatementImpl.java:68)
at weblogic.jdbc.rmi.SerialPreparedStatement.executeUpdate(SerialPreparedStatement.java:58)
at com.scit.pfp.ejb.asset.MacroAssetBean_gosheh__WebLogic_CMP_RDBMS.__WL_create(MacroAssetBean_gosheh__WebLogic_CMP_RDBMS.java:1156)
at com.scit.pfp.ejb.asset.MacroAssetBean_gosheh__WebLogic_CMP_RDBMS.ejbPostCreate(MacroAssetBean_gosheh__WebLogic_CMP_RDBMS.java:1070)
at java.lang.reflect.Method.invoke(Native Method)
at weblogic.ejb20.manager.DBManager.create(DBManager.java:756)
at weblogic.ejb20.manager.DBManager.remoteCreate(DBManager.java:696)
at weblogic.ejb20.internal.EntityEJBHome.create(EntityEJBHome.java:201)
at com.scit.pfp.ejb.asset.MacroAssetBean_gosheh_HomeImpl.create(MacroAssetBean_gosheh_HomeImpl.java:76)
at com.scit.pfp.ejb.asset.MacroAssetBean_gosheh_HomeImpl_WLSkel.invoke(Unknown
Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:342)
at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:103)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:313)
at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:156)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:137)
>
Thanks in advance.
Amit
MacroAssetBean_gosheh__WebLogic_CMP_RDBMS.java
in the routine WL_create() ?
thanks
-thorick
as per your request, i'm sending this section of generated
SQL from MacroAssetBean_gosheh__WebLogic_CMP_RDBMS.java
__WL_query_array[0] = "INSERT INTO ASSETTEMP (ASSET_ID, EXPECTED_RETURN, NAME,
VOLATILITY) VALUES (?, ?, ?, ?)";
The column ASSET_ID is the PK with clustered index and is an Identity column in the
db.
I've configured weblogic 7 properly to use SQL_SERVER identities.
I personally see nothing wrong with this SQL. Could it be a
problem in the mssqlserver4 driver in weblogic.jar while
converting this SQL to native SQL format ?
Eagerly waiting for your response.
Thanks in advance.
amit
As per your request, i'm sending this section of generated
SQL in MacroAssetBean_gosheh__WebLogic_CMP_RDBMS.java
If ASSET_ID is an IDENTITY column then it cannot be listed in the INSERT statement.
I think the best course of action is to declare that the Bean is using
automatic-key-generation via the following declaration in the cmp dd:
<automatic-key-generation>
<generator-type>SQL_SERVER</generator-type>
</automatic-key-generation>
The generated INSERT should then NOT have the ASSET_ID listed in the INSERT statement
and the container will get the PK value from the DB after the INSERT.
hope this helps.
=thorick
your statement makes perfect sense but i'm ALREADY using automatic-key generation.
i have the following entry in weblogic-cmp-rdbms-jar.xml
<automatic-key-generation>
<generator-type>SQL_SERVER<generator-type>
<generator-name>IDENTITY</generator-name>
<key-cache-size>10</key-cache-size>
</automatic-key-generation>
it seems that ejbc is still generating the SQL in MacroAssetBean_goseh_Weblogic_CMP_RDBMS.java
with
"INSERT INTO ASSETTEMP (ASSET_ID, EXPECTED_RETURN, NAME, VOLATILITY) VALUES (?, ?,
?, ?)";
instead of
"INSERT INTO ASSETTEMP (EXPECTED_RETURN, NAME, VOLATILITY) VALUES (?, ?, ?)";
pls suggest what to do.
thanks in advance
Amit
-thorick
Do you also have have something like
<entity>
...
<primkey-field>assetId</primkey-field>
</entity>
in your ejb-jar.xml ? Just in case...
We use autogenerated PKs on WL6.1SP2 + Sybase Adaptive Server, and it works.
Michael Jouravlev.
i'm using WLS 7 beta with ms-sql server 7.
in case this might help (from jdbc log): SQLException: SQLState(01000) vendor code(170)
thanks in advance
amit
yes,i do have the following lines in ejb-jar.xml
<prim-key-class>java.lang.Integer</prim-key-class>
....
<cmp-version>2.x</cmp-version>
...
<cmp-field>
<field-name>assetID</field-name>
</cmp-field>
...
<primkey-field>assetID</primkey-field>
i'm using WLS 7 beta with ms-sql server 7.
in case this might help (from jdbc log):
SQLException: SQLState(01000) vendor code(170)
thanks in advance
Amit
-thorick
>WLS7 Beta. This might have been fixed in WLS7 GA.
>Would it be possible to download the GA version and
>give a quick recompile ?
well i have started downlaoding WLS7 GA over a dial-up line in India where speeds
r painstakingly slow.
hope the problem is fixed with GA.
the WLS 7 download page has windows 2000. but we have NT sp6. hope that doesn't create
a new set of problems. now i can't upgrade the OS(not yet)
i'll get back with the outcome in a day.
thankx
amit
Thankxx a lot for your advice Thorick.
i problem did not occur with WL7 GA. i guess the problem was with the WL 7 beta generated
SQL.
thankx again
amit