Foren

Caused by: java.sql.SQLException: Invalid object name [SOLVED]

thumbnail
Bijan Vakili, geändert vor 12 Jahren.

Caused by: java.sql.SQLException: Invalid object name [SOLVED]

Expert Beiträge: 375 Beitrittsdatum: 10.03.09 Neueste Beiträge
Hi,

Using Liferay 6.0.6 CE, I added a custom service using ext plugin service builder and issue occurs when using SQL Server 2008 database (but not MySQL) on execution of com.liferay.portal.dao.orm.hibernate.SessionImpl.flush() statement.

Stacktrace of the flush() statement call: http://pastebin.com/NFBAdUWh
-note: com.my.portal.ipac package contains the custom service

Exception stacktrace: http://pastebin.com/Ly92MnK0

Log file for the particular action with Log4j category org.hibernate set to ALL : attached catalina.out
-- Lines 9144 through 9356 show the ORMexception

My connection string is as follows:

jdbc.default.driverClassName=net.sourceforge.jtds.jdbc.Driver
jdbc.default.url=jdbc:jtds:sqlserver://server:1433/db
jdbc.default.username=user
jdbc.default.password=password

Any help would be greatly appreciated.

Thanks.
thumbnail
David H Nebinger, geändert vor 12 Jahren.

RE: Caused by: java.sql.SQLException: Invalid object name

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
These kinds of errors are typically due to Hibernate mapping issues. Since it's working in MySQL but not in SQL Server, I'd put my money on an issue w/ your schema declaration (since MySQL does not use schemas but SQL Server does).

Did you use ServiceBuilder to create your entities?
thumbnail
Bijan Vakili, geändert vor 12 Jahren.

RE: Caused by: java.sql.SQLException: Invalid object name (Antwort)

Expert Beiträge: 375 Beitrittsdatum: 10.03.09 Neueste Beiträge
David H Nebinger:
Did you use ServiceBuilder to create your entities?

Yes. However, I convert data types to SQL Server 2008 data types in portal-tables.sql:

INTEGER - int
LONG - bigint
DATE - datetime
varchar - varchar


Those are the only types I use.
The Create Table Script looks as follows:

CREATE TABLE "dbo"."mytable_ipac_service_IPACEntity"
(
   ipacId int PRIMARY KEY NOT NULL,
   companyId bigint,
   userId bigint,
   userName varchar(75),
   createDate datetime,
   modifiedDate datetime,
   groupId bigint,
   plid bigint,
   portletName varchar(75),
   data1 varchar(75),
   data2 varchar(75),
   data3 varchar(75),
   data4 varchar(75),
   data5 varchar(75),
   state int
)
GO
CREATE UNIQUE INDEX PK__mytable_i__AF92AA554C2C2D6D ON "dbo"."mytable_ipac_service_IPACEntity"(ipacId)
GO
CREATE UNIQUE INDEX PK__mytable_i__AF92AA55485B9C89 ON "dbo"."mytable_ipac_service_IPACEntity"(ipacId)
GO


Update: I tried using Microsoft's jdbc driver using following string and issue persists:
jdbc.default.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
jdbc.default.url=jdbc:sqlserver://server:1433;databaseName=database

Next step I will modify the following generated service classes just to get this to work on SQL Server 2008:
com.my.portal.ipac.model.impl.IPACEntityModelImpl

Update: Switching the driver to Microsoft's worked! Earlier I made a mistake in configuration.

Thanks.