-->
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.  [ 5 posts ] 
Author Message
 Post subject: Unsuccessful: create table
PostPosted: Sat Oct 03, 2009 11:33 pm 
Newbie

Joined: Sat Oct 03, 2009 10:59 pm
Posts: 7
dear friends,
i've built a project based on MyEclipse, which have been integrated with struts and hibernate. Some error as follow occured when i run the project.
Quote:
(0 ms) [http-8080-1] ERROR: org.hibernate.tool.hbm2ddl.SchemaUpdate#execute : Unsuccessful: create table tour.base_hotel (id integer not null, typeId_1 integer, totalTime float, totalMoney float, line varchar(255), typeId_2 integer, scenerySpotList text, stopList text, hotel_id integer, hotelName varchar(20), hotelClassType varchar(16), hotelPrice float, primary key (id, typeId_1, totalTime, totalMoney, line, typeId_2, scenerySpotList, stopList, hotel_id, hotelName, hotelClassType, hotelPrice))
(0 ms) [http-8080-1] ERROR: org.hibernate.tool.hbm2ddl.SchemaUpdate#execute : BLOB/TEXT column 'scenerySpotList' used in key specification without a key length
(15 ms) [http-8080-1] ERROR: org.hibernate.tool.hbm2ddl.SchemaUpdate#execute : Unsuccessful: create table tour.problem_hotel (id integer not null, time float, realTime float, money float, realMoney float, relationTime float, relationMoney float, typeid_2 integer, typeid_1 integer, line varchar(45), stopList varchar(45), scenerySpotMoney float, generalLine text, hotel_id integer, contradictionType varchar(10), hotelNo integer, hotelName varchar(20), hotelClassType varchar(16), hotelPrice float, primary key (id, time, realTime, money, realMoney, relationTime, relationMoney, typeid_2, typeid_1, line, stopList, scenerySpotMoney, generalLine, hotel_id, contradictionType, hotelNo, hotelName, hotelClassType, hotelPrice))
(15 ms) [http-8080-1] ERROR: org.hibernate.tool.hbm2ddl.SchemaUpdate#execute : Too many key parts specified; max 16 parts allowed
(15 ms) [http-8080-1] ERROR: org.hibernate.tool.hbm2ddl.SchemaUpdate#execute : Unsuccessful: create table tour.stop_tool (id integer not null, startNo integer, endNo integer, distance float, toolNo integer, startPicture varchar(10), endPicture varchar(10), toolName varchar(16), speed float, price float, startPrice float, startLenght float, primary key (id, startNo, endNo, distance, toolNo, startPicture, endPicture, toolName, speed, price, startPrice, startLenght))
(31 ms) [http-8080-1] ERROR: org.hibernate.tool.hbm2ddl.SchemaUpdate#execute : Table 'stop_tool' already exists

The 'base_hotel' above is a view stem form table 'base' and table 'hotel'. And the 'problem_hotel' and 'stop_tool' have the similar problem.
Here's the tools' version i am using:
hibernate 3.1,
sturts 1.2
MySQL 5.1.11
The mapping file is as follow,
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">
<!--
    Mapping file autogenerated by MyEclipse Persistence Tools
-->
<hibernate-mapping>
    <class name="com.tour.struts.forms.BaseHotel" table="base_hotel" catalog="tour">
        <composite-id name="id" class="com.tour.struts.forms.BaseHotelId">
            <key-property name="id" type="integer">
                <column name="id" />
            </key-property>
            <key-property name="hotel_id" type="integer">
                <column name="hotel_id"/>
            </key-property>
        </composite-id>
            <property name="typeId_1" type="integer">
                <column name="typeId_1" />
            </property>
            <property name="totalTime" type="float">
                <column name="totalTime" precision="22" scale="0"/>
            </property>
            <property name="totalMoney" type="float">
                <column name="totalMoney" precision="22" scale="0" />
            </property>
            <property name="line" type="string">
                <column name="line"/>
            </property>
            <property name="typeId_2" type="integer">
                <column name="typeId_2"/>
            </property>
            <property name="scenerySpotList" type="string">
                <column name="scenerySpotList" length="65535"/>
            </property>
            <property name="stopList" type="string">
                <column name="stopList" length="65535"/>
            </property>
            <property name="hotelName" type="string">
                <column name="hotelName" length="20"/>
            </property>
            <property name="hotelClassType" type="string">
                <column name="hotelClassType" length="16"/>
            </property>
            <property name="hotelPrice" type="float">
                <column name="hotelPrice" precision="12" scale="0"/>
            </property>
    </class>
</hibernate-mapping>

And the hibernate.cfg.xml is
Code:
<?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">

<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>

<session-factory>
   <property name="connection.username">root</property>
   <property name="connection.url">
      jdbc:mysql://localhost:3306/tour?useUnicode=true&amp;characterEncoding=UTF-8
      
   </property>
   
   <property name="dialect">
      org.hibernate.dialect.MySQLDialect
   </property>
   <property name="hbm2ddl.auto">update</property>
   <property name="connection.password">root</property>
   <property name="connection.driver_class">
      com.mysql.jdbc.Driver
   </property>
   <property name="show_sql">true </property>

   <mapping resource="com/tour/table/Base_hotelTable.hbm.xml" />
   <mapping resource="com/tour/table/BaseTable.hbm.xml" />
   <mapping resource="com/tour/table/HotelTable.hbm.xml" />
   <mapping resource="com/tour/table/Problem_hotelTable.hbm.xml" />
   <mapping resource="com/tour/table/ProblemTable.hbm.xml" />
   <mapping resource="com/tour/table/ScenerySpotTable.hbm.xml" />
   <mapping resource="com/tour/table/ScenerySpotTypeTable.hbm.xml" />
   <mapping resource="com/tour/table/Stop_toolTable.hbm.xml" />
   <mapping resource="com/tour/table/StopRelationTable.hbm.xml" />
   <mapping resource="com/tour/table/StopTable.hbm.xml" />
   <mapping resource="com/tour/table/StrategyTable.hbm.xml" />
   <mapping resource="com/tour/table/ToolTable.hbm.xml" />
</session-factory>
</hibernate-configuration>

This problem have perplexed me for days, any constructive suggestion will be appreciated.

Regards,
Iwill


Last edited by iwill on Sun Oct 04, 2009 8:11 am, edited 3 times in total.

Top
 Profile  
 
 Post subject: Re: Unsuccessful: create table
PostPosted: Sun Oct 04, 2009 7:28 am 
Senior
Senior

Joined: Mon Jul 07, 2008 4:35 pm
Posts: 141
Location: Berlin
Hi iwill,

could you please also post the mapping files of the entities in question?

Please use BBCode to enclose your code snippets and stack traces (check the buttons below the subject line). This will be much easier to read then.

CU
Froestel

_________________
Have you tried turning it off and on again? [Roy]


Top
 Profile  
 
 Post subject: Re: Unsuccessful: create table
PostPosted: Sun Oct 04, 2009 8:24 am 
Newbie

Joined: Sat Oct 03, 2009 10:59 pm
Posts: 7
Froestel wrote:
Hi iwill,

could you please also post the mapping files of the entities in question?

Please use BBCode to enclose your code snippets and stack traces (check the buttons below the subject line). This will be much easier to read then.

CU
Froestel


Dear Forestel,
Thank you so much for reminding me of post my question more normal. I have attached the mapping file of the entity of 'Base_hotel' in the original post, look forward to your further suggestion. Thank you!

regards,
Iwill


Top
 Profile  
 
 Post subject: Re: Unsuccessful: create table
PostPosted: Sun Oct 04, 2009 9:01 am 
Senior
Senior

Joined: Mon Jul 07, 2008 4:35 pm
Posts: 141
Location: Berlin
Hi Iwill,

this looks rather complicated since there are several errors.

  • There might be trouble in your mapping for BaseHotel. I'm not sure, but I don't think it is a good idea to have the value for field name in <composite-id> being equal to that of one of its <key-property> name fields. What is this id anyway? Why is there need to have a composite id in this place?
  • Do you use the property scenerySpotList somewhere else? You might have forgotten to add a value for its length attribute.
  • The problem_hotel table has too many key fields, at max. 16 seem to be allowed. (Why even have more than two or three in a key?)
  • The stop_hotel table seems to be mapped more than once - a copy-and-paste error?

Did you actually put up a proper data model that could possibly end up in a straight and normalized database schema. It looks like you have conceptual problems with the theoretical basis of your work.

CU
Froestel

_________________
Have you tried turning it off and on again? [Roy]


Top
 Profile  
 
 Post subject: Re: Unsuccessful: create table
PostPosted: Sun Oct 04, 2009 9:40 am 
Newbie

Joined: Sat Oct 03, 2009 10:59 pm
Posts: 7
Froestel wrote:
Hi Iwill,

this looks rather complicated since there are several errors.

[*]There might be trouble in your mapping for BaseHotel. I'm not sure, but I don't think it is a good idea to have the value for field name in <composite-id> being equal to that of one of its <key-property> name fields. What is this id anyway? Why is there need to have a composite id in this place?
[*]Do you use the property scenerySpotList somewhere else? You might have forgotten to add a value for its length attribute.
[*]The problem_hotel table has too many key fields, at max. 16 seem to be allowed. (Why even have more than two or three in a key?)
[*]The stop_hotel table seems to be mapped more than once - a copy-and-paste error

Did you actually put up a proper data model that could possibly end up in a straight and normalized database schema. It looks like you have conceptual problems with the theoretical basis of your work.

CU
Froestel


Hi Forestel,
you're right, it's very complicated. Definitely, i have just learnt hibernate for several days, there are probably some conceptual problems of my work but i am sure that i have put up a proper data model.

[*]The id is the primary key of table Base, and the hotel_id is the primary key of table hotel. And the view of Base_hotel stem from the table Base and table hotel. Here using the composite-id due to my using the hibernate reverse enginneering , which is also causing there are 16 keys in problem_hotel table.
[*]I've been corrected the second error according to your reminding.
[*]The third error attribute to the hibernate reverse enginneering .
[*]The stop_hotel table have been mapped just once, i am sure. But i don't know what's wrong with it.
Froestel, thanks.

regards,
Iwill


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