Hi there,
Using Hibernate 2.1.4
MS SQL 2000
While trying to perform simple SELECT statements using a named SQL I noticed the following in a stack trace
Code:
HIBERNATE: WARN - SQL Error: 229, SQLState: 42000
HIBERNATE: ERROR - [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]UPDATE permission denied on object 'companies', database 'os', owner 'dbo'.
HIBERNATE: ERROR - could not update: [gr.forthnet.openseas.models.Company#ANEK]
java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]UPDATE permission denied on object 'companies', database 'os', owner 'dbo'.
at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRPCRequest.processReplyToken(Unknown Source)
at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
at com.microsoft.jdbc.sqlserver.SQLServerImplStatement.getNextResultType(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.commonTransitionToState(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.postImplExecute(Unknown Source)
at com.microsoft.jdbc.base.BasePreparedStatement.postImplExecute(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.commonExecute(Unknown Source)
at com.microsoft.jdbc.base.BaseStatement.executeUpdateInternal(Unknown Source)
at com.microsoft.jdbc.base.BasePreparedStatement.executeUpdate(Unknown Source)
at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:22)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:689)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.java:642)
at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:52)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2414)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2368)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2236)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at gr.forthnet.services.connectivity.databases.HiberDatabase.select(HiberDatabase.java:293)
The following code was trying to execute
Code:
public List select(String query, Hashtable params)
{
Session session = getClientSession();
Transaction tx = null;
try
{
tx = session.beginTransaction();
Query sqlQuery = session.getNamedQuery(query);
for(Iterator keys = params.keySet().iterator(); keys.hasNext();)
{
String param = (String)keys.next();
String value = (String)params.get(param);
sqlQuery.setString(param,value);
}
return sqlQuery.list();
....
using the mapping documents below
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping package="gr.forthnet.openseas.models">
<sql-query name="shippingCompanies">
<return alias="company" class="Company"/>
SELECT {company}.COMPANYID AS {company.abbreviation},
{company}.COMPANY_NAME AS {company.name}
FROM companies {company}, agencies_companies agencies_companies
WHERE {company}.COMPANYID = agencies_companies.COMPANY_CODE
AND {company}.COMPANY_TYPE='SEALINES'
AND agencies_companies.AGENCY_CODE= :agencyCode
</sql-query>
</hibernate-mapping>
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping package="gr.forthnet.openseas.models">
<class name="Company" table="companies">
<id name="abbreviation" column="companyID" type="java.lang.String" unsaved-value="null" length="32">
<generator class="hilo"/>
</id>
<property name="name" column="company_name" type="java.lang.String" not-null="true" />
</class>
</hibernate-mapping>
Just today I also noticed that the data in some tables has changed and I was wondering how is it possible if only select statements are made :/
Thanks in advance