-->
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.  [ 3 posts ] 
Author Message
 Post subject: The Id can't be int if I use "native" generator ?!
PostPosted: Mon Aug 30, 2004 10:21 pm 
Senior
Senior

Joined: Wed Dec 17, 2003 4:24 am
Posts: 188
2.1.6

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<class name="lyo.test.bean.Trade" table="tradetest">
<id name="trade_id" column="trade_id">
<generator class="native"/>
</id>
<property name="trade_name" column="trade_name"/>
<property name="trade_desc" column="trade_desc"/>
</class>
</hibernate-mapping>


Configuration cfg=new Configuration().configure();
sf=cfg.buildSessionFactory();
new SchemaExport(cfg).create(true,true);


2004-8-31 10:11:20 net.sf.hibernate.connection.DriverManagerConnectionProvider c
onfigure
信息: connection properties: {user=yashnoo, password=yashnoo}
drop table if exists tradetest
create table tradetest (
trade_id varchar(255) not null auto_increment,
trade_name varchar(255),
trade_desc varchar(255),
primary key (trade_id)
)
2004-8-31 10:11:20 net.sf.hibernate.tool.hbm2ddl.SchemaExport execute
seve: Unsuccessful: create table tradetest (trade_id varchar(255) not null auto_
increment, trade_name varchar(255), trade_desc varchar(255), primary key (trade_
id))
2004-8-31 10:11:20 net.sf.hibernate.tool.hbm2ddl.SchemaExport execute
severity: Invalid argument value: Incorrect column specifier for column 'trade_id'
2004-8-31 10:11:20 net.sf.hibernate.tool.hbm2ddl.SchemaExport execute
info: schema export complete
2004-8-31 10:11:20 net.sf.hibernate.connection.DriverManagerConnectionProvider c
lose
info: cleaning up connection pool: jdbc:mysql://localhost:3306/powersql


3.23.56

info

JavaBean PO is:
Code:
package lyo.test.bean;

public class Trade{
   private String trade_id;
   private String trade_name;
   private String trade_desc;
   
   public String getTrade_id(){
      return this.trade_id;
   }
   public void setTrade_id(String trade_id){
      this.trade_id=trade_id;
   }
   public void setTrade_name(String trade_name){
      this.trade_name=trade_name;
   }
   public String getTrade_name(){
      return this.trade_name;
   }
   public void setTrade_desc(String trade_desc){
      this.trade_desc=trade_desc;
   }
   public String getTrade_desc(){
      return this.trade_desc;
   }

}


Hi everyone:

I want to create table use Hibernate SchemaExport . But I found that If I use native generator create string id hibernate can't create table. And it report error.

The problem is exactly as the same as this:http://opensource.atlassian.com/projects/hibernate/browse/HB-1113

Mysql "native" id generator fails if id's type is String. Why? It hibernate 2.1.6's bug?
Help!

_________________
You are not alone...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 30, 2004 10:26 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Quote:
Mysql "native" id generator fails if id's type is String. Why? It hibernate 2.1.6's bug?


Please be much more careful before throwning the "bug" word around. MySQL does not support varchar for autoincrement columns, I'm not even sure what that could possible -mean-.


Top
 Profile  
 
 Post subject: Sorry
PostPosted: Tue Aug 31, 2004 12:15 am 
Senior
Senior

Joined: Wed Dec 17, 2003 4:24 am
Posts: 188
Sorry. It's my mistake. :-)

_________________
You are not alone...


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