facebook

Problem with hibernate mapping from DB explorer

  1. MyEclipse Archived
  2.  > 
  3. Database Tools (DB Explorer, Hibernate, etc.)
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #224737 Reply

    Edmond Wong
    Member

    Hi,

    I am using MyEclipse IDE v3.8.4 (Eclipse 3.01/JDK1.42), and Hibernate 2.17, and am constructing a test Swing application using the Visual editor plugin. On the project level, I add MyEclipse->Hibernate capability to the test swing application. I also have a sample date contain one table (contact) in MS Access for DB Explorer to build the mapping files. In the project build property, I had added the hibernate2.jar as the library.

    I notice that it has create a partial contact.java bean (missing the setter, and getter methods) and hibernate.cfg.xml (no issue). However, there is a problem with the contact.hbm.xml file:

    Severity Description Resource In Folder Location Creation Time
    2 The content of element type “class” must match “(meta*,(cache|jcs-cache)?,(id|composite-id),discriminator?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|any|map|set|list|bag|idbag|array|primitive-array)*,(subclass*|joined-subclass*))”. Contact.hbm.xml MySQLViewer/com/edmond line 20 February 8, 2005 3:20:21 PM

    on the following excerpt of the Contact.hbm.xml file:

    <hibernate-mapping package=”com.edmond”>

    <class name=”Contact” table=”Contact”>

    <property name=”id” column=”ID” type=”java.lang.Integer” not-null=”true” />
    <property name=”lastname” column=”lastName” type=”java.lang.String” />
    <property name=”firstname” column=”firstName” type=”java.lang.String” />
    <property name=”email” column=”email” type=”java.lang.String” />
    <property name=”daytimephone” column=”daytimePhone” type=”java.lang.String” />
    <property name=”nightimephone” column=”nightimePhone” type=”java.lang.String” />
    <property name=”cellphone” column=”cellPhone” type=”java.lang.String” />
    </class>

    Any Idea?

    Thanks,

    Edmond

    #224743 Reply

    Riyad Kalla
    Member

    Edmond,
    It looks like your table is missing a Primary Key, you can’t map tables that do not have PKs.

    #224745 Reply

    Edmond Wong
    Member

    @support-rkalla wrote:

    Edmond,
    It looks like your table is missing a Primary Key, you can’t map tables that do not have PKs.

    Hi,

    I just verified the primary key was indeed on the “id” column of table “contact” in MS Access. I am wonder if SQL dialect “MS SQL Server” that I have chosen is the cause of the problem. What dialect should I choose?

    Thanks,

    Edmond

    #224748 Reply

    Riyad Kalla
    Member

    I am wonder if SQL dialect “MS SQL Server” that I have chosen is the cause of the problem. What dialect should I choose?

    This very well could be the problem. As far as what dialect to use, unless Hibernate directly supports MS Access, then more than anything I suggest you use another database… not just for this one single reason, but for a whole slew down the road. Access is a good desktop database and can be handy when drafting ideas… but I would certainly never suggest someone write an application against it. There may be ‘reasons’ that Hibernate does not already have an Access dialect, and I would hate for you to get months down the road and find out that you can’t use Hibernate with Access because it doesn’t support some fundamental functionality that you need for your project.

    I would suggest MySQL or PostgreSQL to you. If you are using Access, use MySQL. If you were using MS SQL Server or Oracle and needed an equally functional DB, I’d say use PostgreSQL.

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: Problem with hibernate mapping from DB explorer

You must be logged in to post in the forum log in