=?iso-8859-2?q?=5BD=B3ugie=5D?= javax.transaction.SystemException z hibernate.
Uzytkownik - 27-12-2005 10:24
=?iso-8859-2?q?=5BD=B3ugie=5D?= javax.transaction.SystemException z hibernate.
Próbuje użyć hibernate. Na razie udało mi się tyle, że nie wyskakują żadne błędy podczas kompilowania. Na razie prosta klasa (id + name) i próbuje. Po rozwiązaniu kilku problemów wyskakuje mi to(patrz dalej).
Dla pewności przepisałem dokładnie przykład z podręcznika i próbuje uruchomić.
Wyskakuje coś takiego: % java events.EventManager store 2005-12-25 16:28:06 org.hibernate.cfg.Environment <clinit> INFO: Hibernate 3.1 rc3 2005-12-25 16:28:07 org.hibernate.cfg.Environment <clinit> INFO: hibernate.properties not found 2005-12-25 16:28:07 org.hibernate.cfg.Environment <clinit> INFO: using CGLIB reflection optimizer 2005-12-25 16:28:07 org.hibernate.cfg.Environment <clinit> INFO: using JDK 1.4 java.sql.Timestamp handling 2005-12-25 16:28:07 org.hibernate.cfg.Configuration configure INFO: configuring from resource: /hibernate.cfg.xml 2005-12-25 16:28:07 org.hibernate.cfg.Configuration getConfigurationInputStream INFO: Configuration resource: /hibernate.cfg.xml 2005-12-25 16:28:08 org.hibernate.cfg.Configuration addResource INFO: Reading mappings from resource: events/Event.hbm.xml 2005-12-25 16:28:09 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues INFO: Mapping class: events.Event -> EVENTS 2005-12-25 16:28:10 org.hibernate.cfg.Configuration doConfigure INFO: Configured SessionFactory: null 2005-12-25 16:28:10 org.hibernate.cfg.Configuration secondPassCompile INFO: processing extends queue 2005-12-25 16:28:10 org.hibernate.cfg.Configuration secondPassCompile INFO: processing collection mappings 2005-12-25 16:28:10 org.hibernate.cfg.Configuration secondPassCompile INFO: processing association property references 2005-12-25 16:28:10 org.hibernate.cfg.Configuration secondPassCompile INFO: processing foreign key constraints 2005-12-25 16:28:10 org.hibernate.connection.DriverManagerConnectionPr ovider configure INFO: Using Hibernate built-in connection pool (not for production use!) 2005-12-25 16:28:10 org.hibernate.connection.DriverManagerConnectionPr ovider configure INFO: Hibernate connection pool size: 1 2005-12-25 16:28:10 org.hibernate.connection.DriverManagerConnectionPr ovider configure INFO: autocommit mode: false 2005-12-25 16:28:10 org.hibernate.connection.DriverManagerConnectionPr ovider configure INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/hibernate 2005-12-25 16:28:10 org.hibernate.connection.DriverManagerConnectionPr ovider configure INFO: connection properties: {user=hibernate, password=****} 2005-12-25 16:28:11 org.hibernate.cfg.SettingsFactory buildSettings WARNING: Could not obtain connection metadata com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTION **
java.net.SocketException MESSAGE: java.net.ConnectException: Connection refused
STACKTRACE:
java.net.SocketException: java.net.ConnectException: Connection refused at com.mysql.jdbc.StandardSocketFactory.connect(Stand ardSocketFactory.java:156) at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:284) at com.mysql.jdbc.Connection.createNewIO(Connection.j ava:2555) at com.mysql.jdbc.Connection.<init>(Connection.java:1 485) at com.mysql.jdbc.NonRegisteringDriver.connect(NonReg isteringDriver.java:266) at java.sql.DriverManager.getConnection(DriverManager .java:525) at java.sql.DriverManager.getConnection(DriverManager .java:140) at org.hibernate.connection.DriverManagerConnectionPr ovider.getConnection(DriverManagerConnectionProvid er.java:110) at org.hibernate.cfg.SettingsFactory.buildSettings(Se ttingsFactory.java:72) at org.hibernate.cfg.Configuration.buildSettings(Conf iguration.java:1830) at org.hibernate.cfg.Configuration.buildSessionFactor y(Configuration.java:1150) at util.HibernateUtil.<clinit>(HibernateUtil.java:13) at events.EventManager.createAndStoreEvent(EventManag er.java:22) at events.EventManager.main(EventManager.java:14)
** END NESTED EXCEPTION **
Last packet sent to the server was 66 ms ago. at com.mysql.jdbc.Connection.createNewIO(Connection.j ava:2621) at com.mysql.jdbc.Connection.<init>(Connection.java:1 485) at com.mysql.jdbc.NonRegisteringDriver.connect(NonReg isteringDriver.java:266) at java.sql.DriverManager.getConnection(DriverManager .java:525) at java.sql.DriverManager.getConnection(DriverManager .java:140) at org.hibernate.connection.DriverManagerConnectionPr ovider.getConnection(DriverManagerConnectionProvid er.java:110) at org.hibernate.cfg.SettingsFactory.buildSettings(Se ttingsFactory.java:72) at org.hibernate.cfg.Configuration.buildSettings(Conf iguration.java:1830) at org.hibernate.cfg.Configuration.buildSessionFactor y(Configuration.java:1150) at util.HibernateUtil.<clinit>(HibernateUtil.java:13) at events.EventManager.createAndStoreEvent(EventManag er.java:22) at events.EventManager.main(EventManager.java:14) 2005-12-25 16:28:11 org.hibernate.dialect.Dialect <init> INFO: Using dialect: org.hibernate.dialect.MySQLDialect 2005-12-25 16:28:11 org.hibernate.transaction.TransactionFactoryFactor y buildTransactionFactory INFO: Using default transaction strategy (direct JDBC transactions) 2005-12-25 16:28:11 org.hibernate.transaction.TransactionManagerLookup Factory getTransactionManagerLookup INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended) 2005-12-25 16:28:11 org.hibernate.cfg.SettingsFactory buildSettings INFO: Automatic flush during beforeCompletion(): disabled 2005-12-25 16:28:12 org.hibernate.cfg.SettingsFactory buildSettings INFO: Automatic session close at end of transaction: disabled 2005-12-25 16:28:12 org.hibernate.cfg.SettingsFactory buildSettings INFO: Scrollable result sets: disabled 2005-12-25 16:28:12 org.hibernate.cfg.SettingsFactory buildSettings INFO: JDBC3 getGeneratedKeys(): disabled 2005-12-25 16:28:12 org.hibernate.cfg.SettingsFactory buildSettings INFO: Connection release mode: auto 2005-12-25 16:28:12 org.hibernate.cfg.SettingsFactory buildSettings INFO: Maximum outer join fetch depth: 2 2005-12-25 16:28:12 org.hibernate.cfg.SettingsFactory buildSettings INFO: Default batch fetch size: 1 2005-12-25 16:28:12 org.hibernate.cfg.SettingsFactory buildSettings INFO: Generate SQL with comments: disabled 2005-12-25 16:28:12 org.hibernate.cfg.SettingsFactory buildSettings INFO: Order SQL updates by primary key: disabled 2005-12-25 16:28:12 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory 2005-12-25 16:28:12 org.hibernate.hql.ast.ASTQueryTranslatorFactory <init> INFO: Using ASTQueryTranslatorFactory 2005-12-25 16:28:12 org.hibernate.cfg.SettingsFactory buildSettings INFO: Query language substitutions: {} 2005-12-25 16:28:12 org.hibernate.cfg.SettingsFactory buildSettings INFO: Second-level cache: enabled 2005-12-25 16:28:12 org.hibernate.cfg.SettingsFactory buildSettings INFO: Query cache: disabled 2005-12-25 16:28:12 org.hibernate.cfg.SettingsFactory createCacheProvider INFO: Cache provider: org.hibernate.cache.NoCacheProvider 2005-12-25 16:28:12 org.hibernate.cfg.SettingsFactory buildSettings INFO: Optimize cache for minimal puts: disabled 2005-12-25 16:28:12 org.hibernate.cfg.SettingsFactory buildSettings INFO: Structured second-level cache entries: disabled 2005-12-25 16:28:12 org.hibernate.cfg.SettingsFactory buildSettings INFO: Echoing all SQL to stdout 2005-12-25 16:28:12 org.hibernate.cfg.SettingsFactory buildSettings INFO: Statistics: disabled 2005-12-25 16:28:12 org.hibernate.cfg.SettingsFactory buildSettings INFO: Deleted entity synthetic identifier rollback: disabled 2005-12-25 16:28:12 org.hibernate.cfg.SettingsFactory buildSettings INFO: Default entity-mode: POJO 2005-12-25 16:28:13 org.hibernate.impl.SessionFactoryImpl <init> INFO: building session factory Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: javax/transaction/SystemException Exception in thread "main" java.lang.ExceptionInInitializerError at util.HibernateUtil.<clinit>(HibernateUtil.java:17) at events.EventManager.createAndStoreEvent(EventManag er.java:22) at events.EventManager.main(EventManager.java:14) Caused by: java.lang.NoClassDefFoundError: javax/transaction/SystemException at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:164) at org.hibernate.id.IdentifierGeneratorFactory.class$ (IdentifierGeneratorFactory.java:25) at org.hibernate.id.IdentifierGeneratorFactory.<clini t>(IdentifierGeneratorFactory.java:76) at org.hibernate.mapping.SimpleValue.createIdentifier Generator(SimpleValue.java:152) at org.hibernate.impl.SessionFactoryImpl.<init>(Sessi onFactoryImpl.java:181) at org.hibernate.cfg.Configuration.buildSessionFactor y(Configuration.java:1152) at util.HibernateUtil.<clinit>(HibernateUtil.java:13) ... 2 more
Dla pewności zamieszczam plik hibernate.cfg.xml (jedyny jaki zmieniałem po części): % cat hibernate.cfg.xml <?xml version='1.0' encoding='utf-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings --> <property name="connection.driver_class">com.mysql.jdbc.Driv er</property> <!-- url jest w formie jdbc:baza_danych://host/baza_danych? --> <!-- U mnnie MySQL jest otwarte na sockecie i na 192.168.0.1 --> <property name="connection.url">jdbc:mysql://localhost/hibernate</property> <property name="connection.username">hibernate</property> <property name="connection.password">***</property>
<!-- JDBC connection pool (use the built-in) --> <property name="connection.pool_size">1</property>
<!-- SQL dialect --> <!-- Jak rozumiem to jest dla wszystkich silników? --> <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- Enable Hibernate's automatic session context management --> <property name="current_session_context_class">thread</property>
<!-- Disable the second-level cache --> <property name="cache.provider_class">org.hibernate.cache.No CacheProvider</property>
<!-- Echo all executed SQL to stdout --> <property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup --> <property name="hbm2ddl.auto">create</property>
<mapping resource="events/Event.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Oprócz dwóch pytań w hibernate.cfg.xml mam jeszcze takie: 3. Skąd wziąć klasę javax.transaction.SystemException? W dokumentacji ani widu ani słychu. 4. Zagnieżdżony wyjątek oznacza, że nie może się połączyć? Dlaczego?
Pozdrawiam
PS. Jeśli to pomoże to używam Gentoo PPS. Nie działa zarówno na sun-jdk-1.5.0 jak i blackdown-jdk-1.4.2.03
Bartek Jablonski - 27-12-2005 10:24
On Sun, 25 Dec 2005 16:39:36 +0100, Uzytkownik wrote: > 4. Zagnieżdżony wyjątek oznacza, że nie może się połączyć? Dlaczego?
Tak to wyglada. A mozesz podlaczyc sie do bazy z konsoli?
Bartek
Uzytkownik - 27-12-2005 10:24
Bartek Jablonski napisał:
> On Sun, 25 Dec 2005 16:39:36 +0100, Uzytkownik wrote: >> 4. Zagnieżdżony wyjątek oznacza, że nie może się połączyć? Dlaczego? > > Tak to wyglada. A mozesz podlaczyc sie do bazy z konsoli? > > Bartek
OK. Hibernate(a zapewnie driver) w przeciwieństwie do mysql(program) nie traktuje localhost jako socket.
Zostaje javax :) % java events.EventManager store 2005-12-25 17:15:40 org.hibernate.cfg.Environment <clinit> INFO: Hibernate 3.1 rc3 2005-12-25 17:15:40 org.hibernate.cfg.Environment <clinit> INFO: hibernate.properties not found 2005-12-25 17:15:40 org.hibernate.cfg.Environment <clinit> INFO: using CGLIB reflection optimizer 2005-12-25 17:15:40 org.hibernate.cfg.Environment <clinit> INFO: using JDK 1.4 java.sql.Timestamp handling 2005-12-25 17:15:40 org.hibernate.cfg.Configuration configure INFO: configuring from resource: /hibernate.cfg.xml 2005-12-25 17:15:40 org.hibernate.cfg.Configuration getConfigurationInputStream INFO: Configuration resource: /hibernate.cfg.xml 2005-12-25 17:15:41 org.hibernate.cfg.Configuration addResource INFO: Reading mappings from resource: events/Event.hbm.xml 2005-12-25 17:15:42 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues INFO: Mapping class: events.Event -> EVENTS 2005-12-25 17:15:42 org.hibernate.cfg.Configuration doConfigure INFO: Configured SessionFactory: null 2005-12-25 17:15:42 org.hibernate.cfg.Configuration secondPassCompile INFO: processing extends queue 2005-12-25 17:15:42 org.hibernate.cfg.Configuration secondPassCompile INFO: processing collection mappings 2005-12-25 17:15:42 org.hibernate.cfg.Configuration secondPassCompile INFO: processing association property references 2005-12-25 17:15:42 org.hibernate.cfg.Configuration secondPassCompile INFO: processing foreign key constraints 2005-12-25 17:15:43 org.hibernate.connection.DriverManagerConnectionPr ovider configure INFO: Using Hibernate built-in connection pool (not for production use!) 2005-12-25 17:15:43 org.hibernate.connection.DriverManagerConnectionPr ovider configure INFO: Hibernate connection pool size: 1 2005-12-25 17:15:43 org.hibernate.connection.DriverManagerConnectionPr ovider configure INFO: autocommit mode: false 2005-12-25 17:15:43 org.hibernate.connection.DriverManagerConnectionPr ovider configure INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://192.168.0.1/hibernate 2005-12-25 17:15:43 org.hibernate.connection.DriverManagerConnectionPr ovider configure INFO: connection properties: {user=hibernate, password=****} 2005-12-25 17:15:44 org.hibernate.cfg.SettingsFactory buildSettings INFO: RDBMS: MySQL, version: 5.0.17-log 2005-12-25 17:15:44 org.hibernate.cfg.SettingsFactory buildSettings INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.12 ( $Date: 2005-11-17 15:53:48 +0100 (Thu, 17 Nov 2005) $, $Revision$ ) 2005-12-25 17:15:44 org.hibernate.dialect.Dialect <init> INFO: Using dialect: org.hibernate.dialect.MySQLDialect 2005-12-25 17:15:44 org.hibernate.transaction.TransactionFactoryFactor y buildTransactionFactory INFO: Using default transaction strategy (direct JDBC transactions) 2005-12-25 17:15:44 org.hibernate.transaction.TransactionManagerLookup Factory getTransactionManagerLookup INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended) 2005-12-25 17:15:44 org.hibernate.cfg.SettingsFactory buildSettings INFO: Automatic flush during beforeCompletion(): disabled 2005-12-25 17:15:44 org.hibernate.cfg.SettingsFactory buildSettings INFO: Automatic session close at end of transaction: disabled 2005-12-25 17:15:44 org.hibernate.cfg.SettingsFactory buildSettings INFO: JDBC batch size: 15 2005-12-25 17:15:44 org.hibernate.cfg.SettingsFactory buildSettings INFO: JDBC batch updates for versioned data: disabled 2005-12-25 17:15:44 org.hibernate.cfg.SettingsFactory buildSettings INFO: Scrollable result sets: enabled 2005-12-25 17:15:44 org.hibernate.cfg.SettingsFactory buildSettings INFO: JDBC3 getGeneratedKeys(): enabled 2005-12-25 17:15:44 org.hibernate.cfg.SettingsFactory buildSettings INFO: Connection release mode: auto 2005-12-25 17:15:44 org.hibernate.cfg.SettingsFactory buildSettings INFO: Maximum outer join fetch depth: 2 2005-12-25 17:15:44 org.hibernate.cfg.SettingsFactory buildSettings INFO: Default batch fetch size: 1 2005-12-25 17:15:44 org.hibernate.cfg.SettingsFactory buildSettings INFO: Generate SQL with comments: disabled 2005-12-25 17:15:44 org.hibernate.cfg.SettingsFactory buildSettings INFO: Order SQL updates by primary key: disabled 2005-12-25 17:15:44 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory 2005-12-25 17:15:45 org.hibernate.hql.ast.ASTQueryTranslatorFactory <init> INFO: Using ASTQueryTranslatorFactory 2005-12-25 17:15:45 org.hibernate.cfg.SettingsFactory buildSettings INFO: Query language substitutions: {} 2005-12-25 17:15:45 org.hibernate.cfg.SettingsFactory buildSettings INFO: Second-level cache: enabled 2005-12-25 17:15:45 org.hibernate.cfg.SettingsFactory buildSettings INFO: Query cache: disabled 2005-12-25 17:15:45 org.hibernate.cfg.SettingsFactory createCacheProvider INFO: Cache provider: org.hibernate.cache.NoCacheProvider 2005-12-25 17:15:45 org.hibernate.cfg.SettingsFactory buildSettings INFO: Optimize cache for minimal puts: disabled 2005-12-25 17:15:45 org.hibernate.cfg.SettingsFactory buildSettings INFO: Structured second-level cache entries: disabled 2005-12-25 17:15:45 org.hibernate.cfg.SettingsFactory buildSettings INFO: Echoing all SQL to stdout 2005-12-25 17:15:45 org.hibernate.cfg.SettingsFactory buildSettings INFO: Statistics: disabled 2005-12-25 17:15:45 org.hibernate.cfg.SettingsFactory buildSettings INFO: Deleted entity synthetic identifier rollback: disabled 2005-12-25 17:15:45 org.hibernate.cfg.SettingsFactory buildSettings INFO: Default entity-mode: POJO 2005-12-25 17:15:45 org.hibernate.impl.SessionFactoryImpl <init> INFO: building session factory Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: javax/transaction/SystemException Exception in thread "main" java.lang.ExceptionInInitializerError at util.HibernateUtil.<clinit>(HibernateUtil.java:17) at events.EventManager.createAndStoreEvent(EventManag er.java:22) at events.EventManager.main(EventManager.java:14) Caused by: java.lang.NoClassDefFoundError: javax/transaction/SystemException at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:164) at org.hibernate.id.IdentifierGeneratorFactory.class$ (IdentifierGeneratorFactory.java:25) at org.hibernate.id.IdentifierGeneratorFactory.<clini t>(IdentifierGeneratorFactory.java:76) at org.hibernate.mapping.SimpleValue.createIdentifier Generator(SimpleValue.java:152) at org.hibernate.impl.SessionFactoryImpl.<init>(Sessi onFactoryImpl.java:181) at org.hibernate.cfg.Configuration.buildSessionFactor y(Configuration.java:1152) at util.HibernateUtil.<clinit>(HibernateUtil.java:13) ... 2 more
Pozdrawiam.
Janusz Nykiel - 27-12-2005 10:24
On Sun, 25 Dec 2005 17:17:35 +0100, Uzytkownik wrote:
> Caused by: java.lang.NoClassDefFoundError: javax/transaction/SystemException
Za hibernate-3.1/lib/_README.txt:
" jta.jar (unknown) - Standard JTA API - runtime, required for standalone operation (outside application server) "
....czyli ten jar musi być w classpath, przy kompilacji i przy uruchomieniu.
-- Janusz Nykiel; cynic@poczta.onet.pl
Uzytkownik - 27-12-2005 10:24
Janusz Nykiel napisał:
> On Sun, 25 Dec 2005 17:17:35 +0100, Uzytkownik wrote: > >> Caused by: java.lang.NoClassDefFoundError: javax/transaction/SystemException > > Za hibernate-3.1/lib/_README.txt: > > " > jta.jar (unknown) > - Standard JTA API > - runtime, required for standalone operation (outside application server) > " > > ...czyli ten jar musi być w classpath, przy kompilacji i przy uruchomieniu.
Lub gnu-classpath.
Pozdrawiam
Uzytkownik - 27-12-2005 10:24
Problem nr. 2 - tamten szczęśliwie rozwiązany. Mam taką tabelę: mysql> desc Category; +-------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+--------------+------+-----+---------+----------------+ | id | bigint(20) | NO | PRI | NULL | auto_increment | | name | varchar(255) | YES | UNI | NULL | | +-------+--------------+------+-----+---------+----------------+ 2 rows in set (0.45 sec)
I taką klasę: package org.dyndns.mojastrona.biblog.core;
public class Category { public Category() {}
public void setId(Long id) { this.id = id; }
public Long getId() { return id; }
public void setName(String name) { this.name = name; }
public String getName() { return name; }
private Long id; private String name; }
Klasę zarządzającą: package org.dyndns.mojastrona.biblog.core;
import org.hibernate.*;
class CategoryManager { public static void main(String[] args) { CategoryManager cmg = new CategoryManager();
if(args[0].equals("store")) cmg.createCategory(args[1]);
HibernateUtil.getSessionFactory().close(); }
public Category createCategory(String name) { Session session = HibernateUtil.getSessionFactory().getCurrentSessio n();
session.beginTransaction();
Category theCategory = new Category();
theCategory.setName(name);
session.save(name); session.getTransaction().commit();
return theCategory; } }
I taki plik mapowania: <?xml version="1.0" ?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping> <class name="org.dyndns.mojastrona.biblog.core.Category" table="Category"> <id name="id"> <generator class="native" /> </id> <property name="name" unique="true" /> </class> </hibernate-mapping>
Plik build.xml: <?xml version="1.0"?>
<project name="biblog"> <property name="Project" value="BibLog" /> <property name="project" value="biblog" /> <property name="year" value="2005" /> <property name="version" value="1.0" />
<property name="src" value="src" /> <property name="build" value="build" /> <property name="dest" value="dest" /> <property name="dest.jar" value="${dest}/${project}.jar" /> <property name="docs" value="doc" />
<property name="debug" value="on" /> <property name="optimize" value="off" />
<property name="class-prefix" value="org.dyndns.mojastrona.${project}" /> <property name="package-prefix" value="org/dyndns/mojastrona/${project}" />
<target name="init" depends="clean"> <tstamp /> <mkdir dir="${build}" /> <mkdir dir="${dest}" /> </target>
<target name="compile" depends="init" description="compile the source"> <javac srcdir="${src}" destdir="${build}" debug="${debug}" optimize="${optimize}"/> <copy todir="${build}/" file="${src}/hibernate.cfg.xml" /> <copy todir="${build}/${package-prefix}/core" file="${src}/${package-prefix}/core/Category.hbm.xml" /> </target> <target name="dist" depends="compile"> <jar jarfile="${dest.jar}" basedir="${build}" includes="**/*.xml,**/*.class" /> </target> <target name="clean" description="clean up"> <delete dir="${build}" /> <delete dir="${dest}" /> </target> <target name="run" depends="compile" > <java fork="true" dir="${build}" classname="${class-prefix}.core.${type}Manager"> <arg line="${command}" /> </java> </target> </project>
I takie błędy: [java] INFO: Checking 0 named HQL queries [java] 2005-12-25 21:35:59 org.hibernate.impl.SessionFactoryImpl checkNamedQueries [java] INFO: Checking 0 named SQL queries [java] Exception in thread "main" org.hibernate.MappingException: Unknown entity: java.lang.String [java] at org.hibernate.impl.SessionFactoryImpl.getEntityPer sister(SessionFactoryImpl.java:512) [java] at org.hibernate.impl.SessionImpl.getEntityPersister( SessionImpl.java:1177) [java] at org.hibernate.event.def.AbstractSaveEventListener. saveWithGeneratedId(AbstractSaveEventListener.java :89) [java] at org.hibernate.event.def.DefaultSaveOrUpdateEventLi stener.saveWithGeneratedOrRequestedId(DefaultSaveO rUpdateEventListener.java:186) [java] at org.hibernate.event.def.DefaultSaveEventListener.s aveWithGeneratedOrRequestedId(DefaultSaveEventList ener.java:33) [java] at org.hibernate.event.def.DefaultSaveOrUpdateEventLi stener.entityIsTransient(DefaultSaveOrUpdateEventL istener.java:175) [java] at org.hibernate.event.def.DefaultSaveEventListener.p erformSaveOrUpdate(DefaultSaveEventListener.java:2 7) [java] at org.hibernate.event.def.DefaultSaveOrUpdateEventLi stener.onSaveOrUpdate(DefaultSaveOrUpdateEventList ener.java:70) [java] at org.hibernate.impl.SessionImpl.fireSave(SessionImp l.java:525) [java] at org.hibernate.impl.SessionImpl.save(SessionImpl.ja va:515) [java] at org.hibernate.impl.SessionImpl.save(SessionImpl.ja va:511) [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method) [java] at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39) [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25) [java] at java.lang.reflect.Method.invoke(Method.java:585) [java] at org.hibernate.context.ThreadLocalSessionContext$Tr ansactionProtectionWrapper.invoke(ThreadLocalSessi onContext.java:274) [java] at $Proxy0.save(Unknown Source) [java] at org.dyndns.mojastrona.biblog.core.CategoryManager. createCategory(CategoryManager.java:24) [java] at org.dyndns.mojastrona.biblog.core.CategoryManager. main(CategoryManager.java:10) [java] Java Result: 1
Jak rozumiem ma problem z dopasowaniem java.lang.String na [VAR]CHAR. Jak to zrobić? Co robię źle? Z manuala wynikałoby, że umie to zrobić.
Pozdrawiam
Uzytkownik - 27-12-2005 10:25
Uzytkownik napisał:
> public Category createCategory(String name) { > Session session = HibernateUtil.getSessionFactory().getCurrentSessio n(); > > session.beginTransaction(); > > Category theCategory = new Category(); > > theCategory.setName(name); > > session.save(name); ^^^^ > session.getTransaction().commit(); > > return theCategory; > }
Tu był błąd.
Pozdrawiam
zanotowane.pldoc.pisz.plpdf.pisz.pleffulla.pev.pl
|
Wydajność baz danych w zależności od poziomu izolacji ANSI/ISO
Czy zna (obsługuje) ktoś program Iso Draw ?
MYSQL - kodowanie w ISO-PL
strona plus baza w iso do utf-8
Kodowanie: z iso na utf
Konwesja znaków w dump'ie bazy danych - ISO -> utf-8 -> ISO -> utf-8
=?iso-8859-2?q?Co_oznacza_b=B3=B1d_Warning:_mysql=5Fconnect() _[function.mysql-connect]:_Can't_connect_to_local_MySQL_server_through_sock et_'/var/run/mysqld/mysqld.sock'_(2)_in?=
=?iso-8859-2?q?Informatyka,_Java,_EJB,_Ajax,_Spring=2E_Czy=BF by_to_koniec_=B6wiata,_czy_te=BF_nasze_uczelnie_b= EAd=B1_uczy=B3y_w_ko=F1cu!_czego_praktycznego_=2E= 2E=2E=2E?=
=?iso-8859-2?q?Ati_Mobility_Radeon_X300_W_Notebooku_Jak_Zwi=E Akszy=E6_Ilo=B6=E6_Grafiki_Poprzez_Wsp=F3=B3dziele nie_Z_Ramu=3F=3F=3F?=
=?ISO-8859-2?Q?=AFegnam_si=EA=2E=2E=2E?=
zanotowane.pldoc.pisz.plpdf.pisz.plabsolwenci.keep.pl
Cytat
Decede mihi sole - nie zasłaniaj mi słonca. Gdy kogoś kochasz, jesteś jak stworzyciel świata - na cokolwiek spojrzysz, nabiera to kształtu, wypełnia się barwą, światłem. Powietrze przytula się do ciebie, choćby był mróz, a ty masz w sobie tyle radości, że musisz ją rozdawać wokoło, bo się w tobie nie mieści Hoc fac - tak czyń. A tergo - od tyłu; z tyłu. I czarne włosy posiwieją. Safona |
|