-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 
Author Message
 Post subject: Newbie problem using Hibernate with sql server 2005
PostPosted: Thu Jan 21, 2010 9:26 pm 
Newbie

Joined: Thu Jan 21, 2010 2:56 am
Posts: 7
Hi,

I'm following through the book, 'Hibernate made Easy' and have fallen at the first hurdle. I am attempting to create run ExportSchema for the one table ("User"). The logging shows this when it runs:

12:08:29,203 INFO Version:15 - Hibernate Annotations 3.4.0.GA
12:08:29,218 INFO Environment:560 - Hibernate 3.3.2.GA
12:08:29,218 INFO Environment:593 - hibernate.properties not found
12:08:29,218 INFO Environment:771 - Bytecode provider name : javassist
12:08:29,234 INFO Environment:652 - using JDK 1.4 java.sql.Timestamp handling
12:08:29,343 INFO Version:14 - Hibernate Commons Annotations 3.1.0.GA
12:08:29,359 INFO Configuration:1474 - configuring from resource: /hibernate.cfg.xml
12:08:29,359 INFO Configuration:1451 - Configuration resource: /hibernate.cfg.xml
12:08:29,453 INFO Configuration:1589 - Configured SessionFactory: null
12:08:29,515 INFO Dialect:175 - Using dialect: org.hibernate.dialect.SQLServerDialect
12:08:29,640 INFO AnnotationConfiguration:369 - Hibernate Validator not found: ignoring
12:08:29,656 INFO SchemaExport:226 - Running hbm2ddl schema export
12:08:29,656 INFO SchemaExport:251 - exporting generated schema to database
12:08:29,656 INFO DriverManagerConnectionProvider:64 - Using Hibernate built-in connection pool (not for production use!)
12:08:29,656 INFO DriverManagerConnectionProvider:65 - Hibernate connection pool size: 20
12:08:29,656 INFO DriverManagerConnectionProvider:68 - autocommit mode: false
12:08:29,734 INFO DriverManagerConnectionProvider:103 - using driver: com.microsoft.sqlserver.jdbc.SQLServerDriver at URL: jdbc:sqlserver://CYBERDYNE\SS2005;databaseName=HibernateDB;
12:08:29,734 INFO DriverManagerConnectionProvider:109 - connection properties: {user=sa, password=****}
12:08:30,250 INFO SchemaExport:268 - schema export complete
12:08:30,250 INFO DriverManagerConnectionProvider:170 - cleaning up connection pool: jdbc:sqlserver://CYBERDYNE\SS2005;databaseName=HibernateDB;

which seems to say that the export was successful, but the 'User' table is not created in the HibernateDB database. I'm not sure how this is going wrong.

My config looks like this:

<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
<session-factory>
<property name="connection.url">jdbc:sqlserver://CYBERDYNE\SS2005;databaseName=HibernateDB;integratedSecurity=false;</property>
<property name="connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
<property name="connection.username">sa</property>
<property name="connection.password">sql</property>

<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<property name="current_session_context_class">thread</property>

<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>

<property name="hibernate.show_sql">true</property>
</session-factory>
</hibernate-configuration>


doing a trace on the sql server instance while this runs gives me this information (warning, long)

<?xml version="1.0" encoding="utf-16"?>
<TraceData xmlns="http://tempuri.org/TracePersistence.xsd">
<Header>
<TraceProvider name="Microsoft SQL Server" MajorVersion="9" MinorVersion="0" BuildNumber="0" />
<ServerInformation name="CYBERDYNE\SS2005" />
<ProfilerUI>
<OrderedColumns>
<ID>27</ID>
<ID>1</ID>
<ID>10</ID>
<ID>6</ID>
<ID>11</ID>
<ID>18</ID>
<ID>16</ID>
<ID>17</ID>
<ID>13</ID>
<ID>9</ID>
<ID>12</ID>
<ID>14</ID>
<ID>15</ID>
<ID>2</ID>
</OrderedColumns>
<TracedEvents>
<Event id="14">
<EventColumn id="1" />
<EventColumn id="9" />
<EventColumn id="6" />
<EventColumn id="10" />
<EventColumn id="14" />
<EventColumn id="11" />
<EventColumn id="12" />
</Event>
<Event id="15">
<EventColumn id="15" />
<EventColumn id="16" />
<EventColumn id="9" />
<EventColumn id="13" />
<EventColumn id="17" />
<EventColumn id="6" />
<EventColumn id="10" />
<EventColumn id="14" />
<EventColumn id="18" />
<EventColumn id="11" />
<EventColumn id="12" />
</Event>
<Event id="17">
<EventColumn id="12" />
<EventColumn id="1" />
<EventColumn id="9" />
<EventColumn id="6" />
<EventColumn id="10" />
<EventColumn id="14" />
<EventColumn id="11" />
</Event>
<Event id="10">
<EventColumn id="15" />
<EventColumn id="16" />
<EventColumn id="9" />
<EventColumn id="17" />
<EventColumn id="2" />
<EventColumn id="10" />
<EventColumn id="18" />
<EventColumn id="11" />
<EventColumn id="12" />
<EventColumn id="13" />
<EventColumn id="6" />
<EventColumn id="14" />
</Event>
<Event id="12">
<EventColumn id="15" />
<EventColumn id="16" />
<EventColumn id="1" />
<EventColumn id="9" />
<EventColumn id="17" />
<EventColumn id="6" />
<EventColumn id="10" />
<EventColumn id="14" />
<EventColumn id="18" />
<EventColumn id="11" />
<EventColumn id="12" />
<EventColumn id="13" />
</Event>
<Event id="13">
<EventColumn id="12" />
<EventColumn id="1" />
<EventColumn id="9" />
<EventColumn id="6" />
<EventColumn id="10" />
<EventColumn id="14" />
<EventColumn id="11" />
</Event>
</TracedEvents>
</ProfilerUI>
</Header>
<Events>
<Event id="14" name="Audit Login">
<Column id="1" name="TextData">-- network protocol: TCP/IP
set quoted_identifier on
set arithabort off
set numeric_roundabort off
set ansi_warnings on
set ansi_padding on
set ansi_nulls on
set concat_null_yields_null on
set cursor_close_on_commit off
set implicit_transactions off
set language us_english
set dateformat mdy
set datefirst 7
set transaction isolation level read committed
</Column>
<Column id="11" name="LoginName">sa</Column>
<Column id="10" name="ApplicationName">Microsoft SQL Server JDBC Driver</Column>
<Column id="12" name="SPID">54</Column>
<Column id="14" name="StartTime">2010-01-22T12:21:01.78+11:00</Column>
</Event>
<Event id="13" name="SQL:BatchStarting">
<Column id="1" name="TextData"> set transaction isolation level read committed set implicit_transactions off </Column>
<Column id="11" name="LoginName">sa</Column>
<Column id="10" name="ApplicationName">Microsoft SQL Server JDBC Driver</Column>
<Column id="12" name="SPID">54</Column>
<Column id="14" name="StartTime">2010-01-22T12:21:01.78+11:00</Column>
</Event>
<Event id="12" name="SQL:BatchCompleted">
<Column id="11" name="LoginName">sa</Column>
<Column id="15" name="EndTime">2010-01-22T12:21:01.78+11:00</Column>
<Column id="10" name="ApplicationName">Microsoft SQL Server JDBC Driver</Column>
<Column id="12" name="SPID">54</Column>
<Column id="14" name="StartTime">2010-01-22T12:21:01.78+11:00</Column>
<Column id="16" name="Reads">0</Column>
<Column id="18" name="CPU">0</Column>
<Column id="1" name="TextData"> set transaction isolation level read committed set implicit_transactions off </Column>
<Column id="13" name="Duration">40</Column>
<Column id="17" name="Writes">0</Column>
</Event>
<Event id="13" name="SQL:BatchStarting">
<Column id="1" name="TextData">set implicit_transactions on </Column>
<Column id="11" name="LoginName">sa</Column>
<Column id="10" name="ApplicationName">Microsoft SQL Server JDBC Driver</Column>
<Column id="12" name="SPID">54</Column>
<Column id="14" name="StartTime">2010-01-22T12:21:01.78+11:00</Column>
</Event>
<Event id="12" name="SQL:BatchCompleted">
<Column id="11" name="LoginName">sa</Column>
<Column id="15" name="EndTime">2010-01-22T12:21:01.78+11:00</Column>
<Column id="10" name="ApplicationName">Microsoft SQL Server JDBC Driver</Column>
<Column id="12" name="SPID">54</Column>
<Column id="14" name="StartTime">2010-01-22T12:21:01.78+11:00</Column>
<Column id="16" name="Reads">0</Column>
<Column id="18" name="CPU">0</Column>
<Column id="1" name="TextData">set implicit_transactions on </Column>
<Column id="13" name="Duration">20</Column>
<Column id="17" name="Writes">0</Column>
</Event>
<Event id="13" name="SQL:BatchStarting">
<Column id="1" name="TextData">IF @@TRANCOUNT &gt; 0 COMMIT TRAN</Column>
<Column id="11" name="LoginName">sa</Column>
<Column id="10" name="ApplicationName">Microsoft SQL Server JDBC Driver</Column>
<Column id="12" name="SPID">54</Column>
<Column id="14" name="StartTime">2010-01-22T12:21:01.78+11:00</Column>
</Event>
<Event id="12" name="SQL:BatchCompleted">
<Column id="11" name="LoginName">sa</Column>
<Column id="15" name="EndTime">2010-01-22T12:21:01.78+11:00</Column>
<Column id="10" name="ApplicationName">Microsoft SQL Server JDBC Driver</Column>
<Column id="12" name="SPID">54</Column>
<Column id="14" name="StartTime">2010-01-22T12:21:01.78+11:00</Column>
<Column id="16" name="Reads">0</Column>
<Column id="18" name="CPU">0</Column>
<Column id="1" name="TextData">IF @@TRANCOUNT &gt; 0 COMMIT TRAN</Column>
<Column id="13" name="Duration">32</Column>
<Column id="17" name="Writes">0</Column>
</Event>
<Event id="13" name="SQL:BatchStarting">
<Column id="1" name="TextData">IF @@TRANCOUNT &gt; 0 COMMIT TRAN set implicit_transactions off </Column>
<Column id="11" name="LoginName">sa</Column>
<Column id="10" name="ApplicationName">Microsoft SQL Server JDBC Driver</Column>
<Column id="12" name="SPID">54</Column>
<Column id="14" name="StartTime">2010-01-22T12:21:01.78+11:00</Column>
</Event>
<Event id="12" name="SQL:BatchCompleted">
<Column id="11" name="LoginName">sa</Column>
<Column id="15" name="EndTime">2010-01-22T12:21:01.78+11:00</Column>
<Column id="10" name="ApplicationName">Microsoft SQL Server JDBC Driver</Column>
<Column id="12" name="SPID">54</Column>
<Column id="14" name="StartTime">2010-01-22T12:21:01.78+11:00</Column>
<Column id="16" name="Reads">0</Column>
<Column id="18" name="CPU">0</Column>
<Column id="1" name="TextData">IF @@TRANCOUNT &gt; 0 COMMIT TRAN set implicit_transactions off </Column>
<Column id="13" name="Duration">28</Column>
<Column id="17" name="Writes">0</Column>
</Event>
<Event id="15" name="Audit Logout">
<Column id="11" name="LoginName">sa</Column>
<Column id="15" name="EndTime">2010-01-22T12:21:01.81+11:00</Column>
<Column id="10" name="ApplicationName">Microsoft SQL Server JDBC Driver</Column>
<Column id="12" name="SPID">54</Column>
<Column id="14" name="StartTime">2010-01-22T12:21:01.75+11:00</Column>
<Column id="16" name="Reads">0</Column>
<Column id="18" name="CPU">0</Column>
<Column id="13" name="Duration">60000</Column>
<Column id="17" name="Writes">0</Column>
</Event>
</Events>
</TraceData>


Top
 Profile  
 
 Post subject: Re: Newbie problem using Hibernate with sql server 2005
PostPosted: Fri Jan 22, 2010 12:15 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Using (true, true) in the SchemaExport will allow you to actually see the SQL/DDL generated by the SchemaExport process.

Maybe try using "Users" instead of User. SQL Server might be using USER as a reserved word in the database. :(

Here's a couple of pages of errata for you. Just look at the bottom of the page:

http://www.hiberbook.com/HiberBookWeb/l ... echallenge
http://jpa.ezhibernate.com/Javacode/lea ... echallenge

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject: Re: Newbie problem using Hibernate with sql server 2005
PostPosted: Fri Jan 22, 2010 12:27 am 
Newbie

Joined: Thu Jan 21, 2010 2:56 am
Posts: 7
Cameron McKenzie wrote:
Using (true, true) in the SchemaExport will allow you to actually see the SQL/DDL generated by the SchemaExport process.

Maybe try using "Users" instead of User. SQL Server might be using USER as a reserved word in the database. :(

Here's a couple of pages of errata for you. Just look at the bottom of the page:

http://www.hiberbook.com/HiberBookWeb/l ... echallenge
http://jpa.ezhibernate.com/Javacode/lea ... echallenge


Hi there Cameron. I like your book (except for the problems I'm having).
I changed the User class to Users, and re-ran, but no change. I'm running with (true, true). Where should the DDL be visible? On the console? I don't see it there.


Top
 Profile  
 
 Post subject: Re: Newbie problem using Hibernate with sql server 2005
PostPosted: Fri Jan 22, 2010 1:18 am 
Newbie

Joined: Thu Jan 21, 2010 2:56 am
Posts: 7
Cameron McKenzie wrote:
Using (true, true) in the SchemaExport will allow you to actually see the SQL/DDL generated by the SchemaExport process.

Maybe try using "Users" instead of User. SQL Server might be using USER as a reserved word in the database. :(

Here's a couple of pages of errata for you. Just look at the bottom of the page:

http://www.hiberbook.com/HiberBookWeb/l ... echallenge
http://jpa.ezhibernate.com/Javacode/lea ... echallenge


Here's my JUnit class:

package test;

import org.junit.Test;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.tool.hbm2ddl.SchemaExport;

import com.examscam.model.Users;

public class TestHibernate {

@Test
public void testCreateTable()
{
AnnotationConfiguration config;
config = new AnnotationConfiguration();
config.addAnnotatedClass(Users.class);
config.configure();
new SchemaExport(config).create(true, true);
}

}


And my Users class:

package com.examscam.model;

import javax.persistence.GeneratedValue;
import javax.persistence.Id;

import org.hibernate.annotations.Entity;

@Entity
public class Users {

private Long id;
private String password;

@Id
@GeneratedValue
public void setId(Long id) {
this.id = id;
}
public Long getId() {
return id;
}

public void setPassword(String password) {
this.password = password;
}
public String getPassword() {
return password;
}

}


Top
 Profile  
 
 Post subject: Re: Newbie problem using Hibernate with sql server 2005
PostPosted: Sat Jan 23, 2010 5:27 am 
Newbie

Joined: Thu Jan 21, 2010 2:56 am
Posts: 7
So no-one has any idea what my problem might be?


Top
 Profile  
 
 Post subject: Re: Newbie problem using Hibernate with sql server 2005
PostPosted: Sat Jan 23, 2010 3:04 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Does it do the same thing if you do it in a main method instead of a JUnit class?

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject: Re: Newbie problem using Hibernate with sql server 2005
PostPosted: Sat Jan 23, 2010 7:12 pm 
Newbie

Joined: Thu Jan 21, 2010 2:56 am
Posts: 7
I've just tried it frommain(), with seeming same result. Here's console output, with debug turned on:

10:08:39,625 INFO Version:15 - Hibernate Annotations 3.4.0.GA
10:08:39,640 INFO Environment:560 - Hibernate 3.3.2.GA
10:08:39,640 INFO Environment:593 - hibernate.properties not found
10:08:39,656 INFO Environment:771 - Bytecode provider name : javassist
10:08:39,656 INFO Environment:652 - using JDK 1.4 java.sql.Timestamp handling
10:08:39,765 INFO Version:14 - Hibernate Commons Annotations 3.1.0.GA
10:08:39,765 INFO Configuration:1474 - configuring from resource: /hibernate.cfg.xml
10:08:39,765 INFO Configuration:1451 - Configuration resource: /hibernate.cfg.xml
10:08:39,843 DEBUG DTDEntityResolver:64 - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd]
10:08:39,843 DEBUG DTDEntityResolver:66 - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
10:08:39,843 DEBUG DTDEntityResolver:76 - located [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd] in classpath
10:08:39,890 DEBUG Configuration:1435 - connection.url=jdbc:sqlserver://CYBERDYNE\SS2005;databaseName=HibernateDB;integratedSecurity=false;
10:08:39,890 DEBUG Configuration:1435 - connection.driver_class=com.microsoft.sqlserver.jdbc.SQLServerDriver
10:08:39,890 DEBUG Configuration:1435 - connection.username=sa
10:08:39,890 DEBUG Configuration:1435 - connection.password=sql
10:08:39,890 DEBUG Configuration:1435 - transaction.factory_class=org.hibernate.transaction.JDBCTransactionFactory
10:08:39,890 DEBUG Configuration:1435 - current_session_context_class=thread
10:08:39,890 DEBUG Configuration:1435 - dialect=org.hibernate.dialect.SQLServerDialect
10:08:39,890 DEBUG Configuration:1435 - hibernate.show_sql=true
10:08:39,890 INFO Configuration:1589 - Configured SessionFactory: null
10:08:39,890 DEBUG Configuration:1590 - properties: {hibernate.connection.password=sql, java.runtime.name=Java(TM) SE Runtime Environment, transaction.factory_class=org.hibernate.transaction.JDBCTransactionFactory, sun.boot.library.path=C:\Program Files\Java\jre1.6.0_07\bin, java.vm.version=10.0-b23, hibernate.connection.username=sa, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=;, java.vm.name=Java HotSpot(TM) Client VM, file.encoding.pkg=sun.io, user.country=AU, sun.java.launcher=SUN_STANDARD, sun.os.patch.level=Service Pack 3, java.vm.specification.name=Java Virtual Machine Specification, user.dir=C:\workspace\HibernateTutorial, java.runtime.version=1.6.0_07-b06, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, hibernate.current_session_context_class=thread, java.endorsed.dirs=C:\Program Files\Java\jre1.6.0_07\lib\endorsed, os.arch=x86, java.io.tmpdir=C:\DOCUME~1\John\LOCALS~1\Temp\, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, os.name=Windows XP, sun.jnu.encoding=Cp1252, java.library.path=C:\Program Files\Java\jre1.6.0_07\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jre6/bin/client;C:/Program Files/Java/jre6/bin;C:\Program Files\PC Connectivity Solution\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\ATI Technologies\ATI Control Panel;C:\Program Files\glassfish-v2ur2\bin;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Microsoft SQL Server\90\DTS\Binn\;C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\, java.specification.name=Java Platform API Specification, java.class.version=50.0, sun.management.compiler=HotSpot Client Compiler, hibernate.transaction.factory_class=org.hibernate.transaction.JDBCTransactionFactory, os.version=5.1, connection.password=sql, user.home=C:\Documents and Settings\John, user.timezone=Australia/Sydney, connection.username=sa, java.awt.printerjob=sun.awt.windows.WPrinterJob, file.encoding=Cp1252, java.specification.version=1.6, hibernate.connection.driver_class=com.microsoft.sqlserver.jdbc.SQLServerDriver, user.name=John, java.class.path=C:\workspace\HibernateTutorial\bin;C:\workspace\HibernateTutorial\libs\Microsoft SQL Server JDBC Driver 2.0\sqljdbc_2.0\enu\sqljdbc4.jar;C:\workspace\HibernateTutorial\libs\hibernate-annotations-3.4.0.GA\hibernate-annotations.jar;C:\workspace\HibernateTutorial\libs\hibernate-distribution-3.3.2.GA\lib\bytecode\cglib\cglib-2.2.jar;C:\workspace\HibernateTutorial\libs\hibernate-distribution-3.3.2.GA\lib\bytecode\javassist\javassist-3.9.0.GA.jar;C:\workspace\HibernateTutorial\libs\hibernate-distribution-3.3.2.GA\lib\required\antlr-2.7.6.jar;C:\workspace\HibernateTutorial\libs\hibernate-distribution-3.3.2.GA\lib\required\commons-collections-3.1.jar;C:\workspace\HibernateTutorial\libs\hibernate-distribution-3.3.2.GA\lib\required\dom4j-1.6.1.jar;C:\workspace\HibernateTutorial\libs\hibernate-distribution-3.3.2.GA\lib\required\javassist-3.9.0.GA.jar;C:\workspace\HibernateTutorial\libs\hibernate-distribution-3.3.2.GA\lib\required\jta-1.1.jar;C:\workspace\HibernateTutorial\libs\hibernate-distribution-3.3.2.GA\lib\required\slf4j-api-1.5.8.jar;C:\workspace\HibernateTutorial\libs\hibernate-distribution-3.3.2.GA\hibernate-testing.jar;C:\workspace\HibernateTutorial\libs\hibernate-distribution-3.3.2.GA\hibernate3.jar;C:\workspace\HibernateTutorial\libs\hibernate-annotations-3.4.0.GA\lib\ejb3-persistence.jar;C:\workspace\HibernateTutorial\libs\hibernate-annotations-3.4.0.GA\lib\hibernate-commons-annotations.jar;C:\workspace\HibernateTutorial\libs\hibernate-annotations-3.4.0.GA\ivy\ivy-1.4.1.jar;C:\workspace\HibernateTutorial\libs\hibernate-annotations-3.4.0.GA\ivy\maven-ant-tasks.jar;C:\workspace\HibernateTutorial\libs\hibernate-annotations-3.4.0.GA\lib\build\ant-contrib-1.0b2.jar;C:\workspace\HibernateTutorial\libs\hibernate-annotations-3.4.0.GA\lib\build\ant-junit-1.6.5.jar;C:\workspace\HibernateTutorial\libs\hibernate-annotations-3.4.0.GA\lib\build\junit-3.8.1.jar;C:\workspace\HibernateTutorial\libs\hibernate-annotations-3.4.0.GA\lib\test\antlr.jar;C:\workspace\HibernateTutorial\libs\hibernate-annotations-3.4.0.GA\lib\test\asm-attrs.jar;C:\workspace\HibernateTutorial\libs\hibernate-annotations-3.4.0.GA\lib\test\asm.jar;C:\workspace\HibernateTutorial\libs\hibernate-annotations-3.4.0.GA\lib\test\commons-collections.jar;C:\workspace\HibernateTutorial\libs\hibernate-annotations-3.4.0.GA\lib\test\javassist.jar;C:\workspace\HibernateTutorial\libs\hibernate-annotations-3.4.0.GA\lib\test\jta.jar;C:\workspace\HibernateTutorial\libs\hibernate-annotations-3.4.0.GA\lib\test\junit.jar;C:\workspace\HibernateTutorial\libs\hibernate-annotations-3.4.0.GA\lib\test\log4j.jar;C:\workspace\HibernateTutorial\libs\hibernate-annotations-3.4.0.GA\lib\test\slf4j-log4j12.jar;C:\workspace\HibernateTutorial\libs\hibernate-annotations-3.4.0.GA\lib\dom4j.jar;C:\workspace\HibernateTutorial\libs\hibernate-annotations-3.4.0.GA\lib\hibernate-core.jar;C:\workspace\HibernateTutorial\libs\hibernate-annotations-3.4.0.GA\lib\slf4j-api.jar;C:\workspace\HibernateTutorial\libs\hibernate-distribution-3.3.2.GA\lib\optional\c3p0\c3p0-0.9.1.jar;C:\workspace\HibernateTutorial\libs\hibernate-distribution-3.3.2.GA\lib\optional\ehcache\ehcache-1.2.3.jar;C:\workspace\HibernateTutorial\libs\hibernate-distribution-3.3.2.GA\lib\optional\jbosscache\jboss-cache-1.4.1.GA.jar;C:\workspace\HibernateTutorial\libs\hibernate-distribution-3.3.2.GA\lib\optional\jbosscache2\jbosscache-core-3.1.0.GA.jar;C:\workspace\HibernateTutorial\libs\hibernate-distribution-3.3.2.GA\lib\optional\oscache\oscache-2.1.jar;C:\workspace\HibernateTutorial\libs\hibernate-distribution-3.3.2.GA\lib\optional\proxool\proxool-0.8.3.jar;C:\workspace\HibernateTutorial\libs\hibernate-distribution-3.3.2.GA\lib\optional\swarmcache\swarmcache-1.0RC2.jar;C:\Program Files\eclipse\plugins\org.junit4_4.3.1\junit.jar, hibernate.bytecode.use_reflection_optimizer=false, hibernate.show_sql=true, current_session_context_class=thread, java.vm.specification.version=1.0, java.home=C:\Program Files\Java\jre1.6.0_07, sun.arch.data.model=32, hibernate.dialect=org.hibernate.dialect.SQLServerDialect, hibernate.connection.url=jdbc:sqlserver://CYBERDYNE\SS2005;databaseName=HibernateDB;integratedSecurity=false;, user.language=en, java.specification.vendor=Sun Microsystems Inc., awt.toolkit=sun.awt.windows.WToolkit, java.vm.info=mixed mode, java.version=1.6.0_07, java.ext.dirs=C:\Program Files\Java\jre1.6.0_07\lib\ext;C:\WINDOWS\Sun\Java\lib\ext, sun.boot.class.path=C:\Program Files\Java\jre1.6.0_07\lib\resources.jar;C:\Program Files\Java\jre1.6.0_07\lib\rt.jar;C:\Program Files\Java\jre1.6.0_07\lib\sunrsasign.jar;C:\Program Files\Java\jre1.6.0_07\lib\jsse.jar;C:\Program Files\Java\jre1.6.0_07\lib\jce.jar;C:\Program Files\Java\jre1.6.0_07\lib\charsets.jar;C:\Program Files\Java\jre1.6.0_07\classes, java.vendor=Sun Microsystems Inc., connection.driver_class=com.microsoft.sqlserver.jdbc.SQLServerDriver, file.separator=\, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, sun.io.unicode.encoding=UnicodeLittle, sun.cpu.endian=little, sun.desktop=windows, connection.url=jdbc:sqlserver://CYBERDYNE\SS2005;databaseName=HibernateDB;integratedSecurity=false;, dialect=org.hibernate.dialect.SQLServerDialect, sun.cpu.isalist=pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86}
10:08:39,984 INFO Dialect:175 - Using dialect: org.hibernate.dialect.SQLServerDialect
10:08:40,031 DEBUG AnnotationConfiguration:258 - Execute first pass mapping processing
10:08:40,125 DEBUG AnnotationConfiguration:529 - Process hbm files
10:08:40,125 DEBUG AnnotationConfiguration:537 - Process annotated classes
10:08:40,125 DEBUG AnnotationConfiguration:401 - processing fk mappings (*ToOne and JoinedSubclass)
10:08:40,125 DEBUG Configuration:1167 - processing extends queue
10:08:40,125 DEBUG Configuration:1171 - processing collection mappings
10:08:40,125 DEBUG Configuration:1182 - processing native query and ResultSetMapping mappings
10:08:40,125 DEBUG Configuration:1190 - processing association property references
10:08:40,125 DEBUG Configuration:1212 - processing foreign key constraints
10:08:40,125 INFO AnnotationConfiguration:369 - Hibernate Validator not found: ignoring
10:08:40,125 DEBUG AnnotationConfiguration:258 - Execute first pass mapping processing
10:08:40,125 DEBUG AnnotationConfiguration:529 - Process hbm files
10:08:40,125 DEBUG AnnotationConfiguration:537 - Process annotated classes
10:08:40,125 DEBUG AnnotationConfiguration:401 - processing fk mappings (*ToOne and JoinedSubclass)
10:08:40,125 DEBUG Configuration:1167 - processing extends queue
10:08:40,125 DEBUG Configuration:1171 - processing collection mappings
10:08:40,125 DEBUG Configuration:1182 - processing native query and ResultSetMapping mappings
10:08:40,125 DEBUG Configuration:1190 - processing association property references
10:08:40,125 DEBUG Configuration:1212 - processing foreign key constraints
10:08:40,140 INFO SchemaExport:226 - Running hbm2ddl schema export
10:08:40,140 DEBUG SchemaExport:242 - import file not found: /import.sql
10:08:40,140 INFO SchemaExport:251 - exporting generated schema to database
10:08:40,140 INFO DriverManagerConnectionProvider:64 - Using Hibernate built-in connection pool (not for production use!)
10:08:40,140 INFO DriverManagerConnectionProvider:65 - Hibernate connection pool size: 20
10:08:40,140 INFO DriverManagerConnectionProvider:68 - autocommit mode: false
10:08:40,281 INFO DriverManagerConnectionProvider:103 - using driver: com.microsoft.sqlserver.jdbc.SQLServerDriver at URL: jdbc:sqlserver://CYBERDYNE\SS2005;databaseName=HibernateDB;integratedSecurity=false;
10:08:40,281 INFO DriverManagerConnectionProvider:106 - connection properties: {user=sa, password=sql}
10:08:40,281 DEBUG DriverManagerConnectionProvider:132 - opening new JDBC connection
10:08:41,000 DEBUG DriverManagerConnectionProvider:138 - created connection to: jdbc:sqlserver://CYBERDYNE\SS2005;databaseName=HibernateDB;integratedSecurity=false;, Isolation Level: 2
10:08:41,000 INFO SchemaExport:268 - schema export complete
10:08:41,000 INFO DriverManagerConnectionProvider:170 - cleaning up connection pool: jdbc:sqlserver://CYBERDYNE\SS2005;databaseName=HibernateDB;integratedSecurity=false;


Top
 Profile  
 
 Post subject: Re: Newbie problem using Hibernate with sql server 2005
PostPosted: Sun Jan 24, 2010 12:20 am 
Newbie

Joined: Thu Jan 21, 2010 2:56 am
Posts: 7
Found the source of the initial problem... @Entity was not java.persistence.Entity.

Now when I run I get this exception:

Exception in thread "main" org.hibernate.AnnotationException: No identifier specified for entity: com.examscam.model.Users
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:672)
at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:546)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:291)
at org.hibernate.cfg.Configuration.generateDropSchemaScript(Configuration.java:803)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:128)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:91)
at test.TestHibernate.main(TestHibernate.java:30)


But the @Id annotation looks fine to me. (javax.persistence.Id).

So... hmmm.


Top
 Profile  
 
 Post subject: Re: Newbie problem using Hibernate with sql server 2005
PostPosted: Sun Jan 24, 2010 1:56 am 
Newbie

Joined: Thu Jan 21, 2010 2:56 am
Posts: 7
So it's all my fault. The @Id annotation was on the setId method, not the getId method.
Table is now being created.


Top
 Profile  
 
 Post subject: Re: Newbie problem using Hibernate with sql server 2005
PostPosted: Sun Jan 24, 2010 11:30 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Sometimes, it really is the most basic stuff than can slow you down and trip you up. Sorry I didn't spot that myself. :(

Enjoy the rest of the book!

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.