-->
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: hbm2ddl not generating all columns
PostPosted: Tue Dec 07, 2010 10:21 pm 
Newbie

Joined: Tue Dec 07, 2010 3:16 pm
Posts: 3
I have the following hbm file:


Code:
<?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="com.vaanila.course.Course" table="COURSES">
        <meta attribute="class-description">
            This class contains the course details.
        </meta>
        <id name="courseId" type="long" column="COURSE_ID">
            <generator class="native"/>
        </id>
        <property name="courseName" type="string" column="COURSE_NAME" not-null="true" />
        <property name="dateTime" type="calendar" column="DATE_TIME" not-null="true" />
    </class>

</hibernate-mapping>


When hbm2ddl runs, it creates the course.h2.db file, it creates the COURSES table, and it creates the COURSE_ID and COURSE_NAME columns with types of BIGINT and VARCHAR. But it does not create the DATE_TIME column at all. There is no entry for it. Additionally, when the entire program runs, the console output shows that my program is inserting and updating information (including the DATE_TIME field), but there is no data in the DB when I check it with an external SQL Client.


Top
 Profile  
 
 Post subject: Re: hbm2ddl not generating all columns
PostPosted: Wed Dec 08, 2010 7:56 am 
Senior
Senior

Joined: Fri May 08, 2009 12:27 pm
Posts: 168
Is "calendar" a valid Hibernate type?
The Hibernate type names differ from Java, JDBC, and database type names.

I think Hibernate tries to do something sensible with names from all these domains, making it hard to figure out which kind of name is used in any situation.
YMWV (Your Mileage Will Vary), since I'm doing reverse engineering and you're doing forward engineering. For reveng, the type names to use in configuration files are the set of predefined types, plus the fully qualified names of "user type" (actually translator) classes.


Top
 Profile  
 
 Post subject: Re: hbm2ddl not generating all columns
PostPosted: Wed Dec 08, 2010 10:52 am 
Newbie

Joined: Tue Dec 07, 2010 3:16 pm
Posts: 3
Yes, calendar is a valid type, and the code works without errors or warnings. The column just doesn't show up in the database. However, I'm not opposed to trying the reverse engineering route. Since I'm just learning Hibernate, I'm willing to try anything to find the best solution that works for me.


Top
 Profile  
 
 Post subject: Re: hbm2ddl not generating all columns
PostPosted: Mon Dec 13, 2010 6:25 am 
Senior
Senior

Joined: Fri May 08, 2009 12:27 pm
Posts: 168
Hibernate Tools tend to silently ignore stuff that they don't know about, so a silent generation run does not mean that the type is known.


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.