-->
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.  [ 4 posts ] 
Author Message
 Post subject: Problem with java.lang.String
PostPosted: Mon Dec 26, 2005 9:10 am 
Newbie

Joined: Sun Dec 25, 2005 12:03 pm
Posts: 12
Hibernate version:
Hibernate 3.1

Mapping documents:
Code:
package org.dyndns.mojastrona.biblog.core;

public class Category {
     public Category() {}

     public void setId(Long i) {
          this.id = i;
     }

     public Long getId() {
          return id;
     }

     public void setName(String n) {
          this.name = n;
     }

     public String getName() {
          return name;
     }

     private Long id;
     private String name;
}

Code:
<?xml version="1.0" encoding="utf-8"?>
<!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" column="CATEGORY_ID">
      <generator class="native" />
    </id>
    <property name="name" column="CATEGORY_NAME" unique="true" />
  </class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
Code:
          session.beginTransaction();

          Category theCategory = new Category();

          theCategory.setName(name);

          session.save(name);
          session.getTransaction().commit();

          return theCategory;

Full stack trace of any exception that occurs:
Code:
     [java] WARNING: could not create proxy factory for:org.dyndns.mojastrona.biblog.core.Category
     [java] org.hibernate.HibernateException: CGLIB Enhancement failed: org.dyndns.mojastrona.biblog.core.Category
     [java]     at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:132)
     [java]     at org.hibernate.proxy.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:41)
     [java]     at org.hibernate.tuple.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:161)
     [java]     at org.hibernate.tuple.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:131)
     [java]     at org.hibernate.tuple.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
     [java]     at org.hibernate.tuple.TuplizerLookup.create(TuplizerLookup.java:64)
     [java]     at org.hibernate.tuple.EntityMetamodel.<init>(EntityMetamodel.java:249)
     [java]     at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:411)
     [java]     at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:108)
     [java]     at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
     [java]     at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:215)
     [java]     at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1152)
     [java]     at org.dyndns.mojastrona.biblog.core.HibernateUtil.<clinit>(HibernateUtil.java:16)
     [java]     at org.dyndns.mojastrona.biblog.core.CategoryManager.createCategory(CategoryManager.java:16)
     [java]     at org.dyndns.mojastrona.biblog.core.CategoryManager.main(CategoryManager.java:10)
     [java] Caused by: java.lang.NoSuchMethodError: net.sf.cglib.proxy.Enhancer.setInterceptDuringConstruction(Z)V
     [java]     at org.hibernate.proxy.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:118)
     [java]     ... 14 more
     [java] 2005-12-26 11:05:47 org.hibernate.impl.SessionFactoryObjectFactory addInstance
     [java] INFO: Not binding factory to JNDI, no JNDI name configured
     [java] 2005-12-26 11:05:47 org.hibernate.tool.hbm2ddl.SchemaUpdate execute
     [java] INFO: Running hbm2ddl schema update
     [java] 2005-12-26 11:05:47 org.hibernate.tool.hbm2ddl.SchemaUpdate execute
     [java] INFO: fetching database metadata
     [java] 2005-12-26 11:05:47 org.hibernate.tool.hbm2ddl.SchemaUpdate execute
     [java] INFO: updating schema
     [java] 2005-12-26 11:05:47 org.hibernate.cfg.Configuration secondPassCompile
     [java] INFO: processing extends queue
     [java] 2005-12-26 11:05:47 org.hibernate.cfg.Configuration secondPassCompile
     [java] INFO: processing collection mappings
     [java] 2005-12-26 11:05:47 org.hibernate.cfg.Configuration secondPassCompile
     [java] INFO: processing association property references
     [java] 2005-12-26 11:05:47 org.hibernate.cfg.Configuration secondPassCompile
     [java] INFO: processing foreign key constraints
     [java] 2005-12-26 11:05:47 org.hibernate.tool.hbm2ddl.TableMetadata <init>
     [java] INFO: table found: library.Category
     [java] 2005-12-26 11:05:47 org.hibernate.tool.hbm2ddl.TableMetadata <init>
     [java] INFO: columns: [category_id, category_name]
     [java] 2005-12-26 11:05:47 org.hibernate.tool.hbm2ddl.TableMetadata <init>
     [java] INFO: foreign keys: []
     [java] 2005-12-26 11:05:47 org.hibernate.tool.hbm2ddl.TableMetadata <init>
     [java] INFO: indexes: [primary, category_name]
     [java] 2005-12-26 11:05:47 org.hibernate.tool.hbm2ddl.SchemaUpdate execute
     [java] INFO: schema update complete
     [java] 2005-12-26 11:05:47 org.hibernate.connection.DriverManagerConnectionProvider close
     [java] INFO: cleaning up connection pool: jdbc:mysql://router/library
     [java] 2005-12-26 11:05:47 org.hibernate.impl.SessionFactoryImpl checkNamedQueries
     [java] INFO: Checking 0 named HQL queries
     [java] 2005-12-26 11:05:47 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.getEntityPersister(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.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186)
     [java]     at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
     [java]     at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175)
     [java]     at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
     [java]     at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
     [java]     at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:525)     [java]     at org.hibernate.impl.SessionImpl.save(SessionImpl.java:515)
     [java]     at org.hibernate.impl.SessionImpl.save(SessionImpl.java:511)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [java]     at java.lang.reflect.Method.invoke(Method.java:585)
     [java]     at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.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)

Name and version of the database you are using:
MySQL 5.0
The generated SQL (show_sql=true):
show_sql=true but no sql.
Debug level Hibernate log excerpt:

I've done first example from the reference documentation and it works.
I've try to do somthing own. But it seems to don't recognize java.lang.String.
I've try which id/name coulumn and CATEGORY_ID/NAME column and VARCAHAR/CHAR and TEXT type of name. All it have the same result.

1. What's wrong?
2. Do yoiu know any CLI debbugger for Java on GNU/Linux?

Regards.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 26, 2005 1:33 pm 
Newbie

Joined: Sun Dec 25, 2005 12:03 pm
Posts: 12
I'm stupid, doesn't I?

Code:
          //session.save(name);
          session.save(theCategory);


I'm so sorry.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 26, 2005 1:34 pm 
Newbie

Joined: Sun Dec 25, 2005 12:03 pm
Posts: 12
Quote:
I'm stupid, doesn't I?


Yes. I am. I'm stupid don't I...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 26, 2005 2:06 pm 
Newbie

Joined: Sun Dec 25, 2005 12:03 pm
Posts: 12
Uzytkownik wrote:
Quote:
I'm stupid, doesn't I?


Yes. I am. I'm stupid don't I...

Once more: I'm stupid, don't I?
Ufff. Now it's ok.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.