• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem with namingstrategy  RSS feed

Ramakrishnan Kartik
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Am a newbie to hibernate and i've been trying to figure out whats wrong with one of my starters.

My mapping file looks like this :

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

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"

<hibernate-mapping package="com.kartik.example">
<class name="Employee" table="EMPLOYEE_TBL">
<id name="empId">
<generator class="native" />
<property name="age"/>
<property name="name"/>

The hibernate.properties file that i employ is:

hibernate.dialect= org.hibernate.dialect.SQLServerDialect
hibernate.connection.driver_class= com.microsoft.jdbc.sqlserver.SQLServerDriver
hibernate.connection.url= jdbc:microsoft:sqlserver://localhost:1433
hibernate.connection.username= sa
hibernate.connection.password= sa
hibernate.show_sql= true

Db is SQL server 2k. I get an exception while trying to insert a record into the employee table using the following code::

Properties propFileContents = new Properties();
Configuration cfg= new Configuration()

The exception is (am mgiving the main stuff alone here):

Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not insert: [com.kartik.example.Employee]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
Caused by: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Invalid object name 'employee_tbl'.
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)

Pls note that i have not created the table Employee in the db yet and i hope the property hibernate.hbm2.ddl_auto=create would take care of that.

Can someone pls help me out

Mladen Grabowsky
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is that there is no DB selected or the wrong DB is selected.
User sa ususally has a standard schema.
You can select the DB via the connection url or create a new db user and set a standard schema for him.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!