• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem with Hibernate Mapping

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hallo,

Hi, I've got a problem with a selection of a datarow from a MySql Table, and I really dont know whats going wrong here

Hibernate version:

Mapping documents:

<hibernate-mapping package="model">
<class name="Adwords" table="adwords" dynamic-update="true">

<id name="id" type="int">
<generator class="native" />
</id>

<property name="Datum" type="string"/>
<property name="Kampagne" type="string"/>
<property name="Anzeigengruppe" type="string"/>
<property name="Keyword" type="string"/>
<property name="Uebereinstimmung" type="string"/>
<property name="Status" type="string"/>
<property name="MaxCPC" type="long"/>
<property name="Url" type="string"/>
<property name="Impressionen" type="int"/>
<property name="Klicks" type="int"/>
<property name="CTR" type="float"/>
<property name="Kosten" type="long"/>
<property name="AdGroupID" type="long"/>
<property name="CriterionID" type="long"/>
<property name="Position" type="float"/>

</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
session = sessionFactory.openSession();
Query query = session.createSQLQuery("select * from adwords");
List result = query.list();
Adwords adword = (Adwords) result.get(0);
System.out.println(adword.getId());

Full stack trace of any exception that occurs:
Exception in thread "main" org.hibernate.MappingException: No Dialect mapping for JDBC type: 7
at org.hibernate.dialect.TypeNames.get(TypeNames.java:56)
at org.hibernate.dialect.TypeNames.get(TypeNames.java:81)
at org.hibernate.dialect.Dialect.getHibernateTypeName(Dialect.java:192)
at org.hibernate.loader.custom.CustomLoader.getHibernateType(CustomLoader.java:161)
at org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:131)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1678)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:111)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1655)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:164)
at model.AWEDBVerbindung.getAlleAdwords(AWEDBVerbindung.java:33)
at model.RunTest.main(RunTest.java:28)


Name and version of the database you are using:
MySQL

The generated SQL (show_sql=true):
select * from adwords;


The "Dialect" Property is set to "org.hibernate.dialect.MySQLDialect".

Anyone have an idea?

[ September 14, 2006: Message edited by: Sascha Rrrrrr ]
[ September 14, 2006: Message edited by: Sascha Rrrrrr ]
 
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think the mysql hibernate dialect supports a LONG datatype. Try NUMERIC instead.
[ September 14, 2006: Message edited by: Scott Johnson ]
 
Sascha Ruehlow
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I changed it to integer, but the problem still remains?
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Sascha Rrrrrr",
Welcome to the JavaRanch.

We're a friendly group, but we do require members to have valid display names.

Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with display names get deleted, often without warning

thanks,
Dave
 
Sascha Ruehlow
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, didn't read this one, changed it.
(Not a good start here...)
 
Scott Johnson
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you change all of the longs to ints?

What's the number after "No Dialect mapping for JDBC type"? Is it still 7?
 
Sascha Ruehlow
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, its still the same.
Is there a tutorial what the types mean?
 
Scott Johnson
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is one of the columns in the adwords table defined as a datatype of real?

java.sql.Types.REAL = 7.

The MySQLDialect does not define a type real.

Try casting any real columns to float or double in the sql and see if that eliminates the exception.
 
Sascha Ruehlow
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I changed all types to Integer, Float and String (really easy db i thought), so there are no experiments or exotic types.

Here's the test-connection, maybe theres something wrong with this?


[ September 16, 2006: Message edited by: Sascha Ruehlow ]
 
Scott Johnson
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you post the create table statement for the adwords table?

The problem may be in the resultset itself and not the mapping.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic