- This topic has 17 replies, 8 voices, and was last updated 18 years, 9 months ago by azorba.
-
AuthorPosts
-
bradmMemberI have a dreadfully simple SQL Server table that I’m trying to let MyEclipse generate a mapping file for. There are only three columns, including the key. Not only does the generated file take no notice of the id field, the IDE give me the dreaded red x at the close of the </class> element, with this error:
“the Contents of element type ‘Class’ must match [yada yada].”
The mapping file is simply
<hibernate-mapping package=”fundingdocuments”>
<class name=”LetterTypes” table=”Letter_Types”>
<property name=”lettertypeid” column=”LetterTypeID” type=”java.lang.Integer” not-null=”true” />
<property name=”lettertype” column=”LetterType” type=”java.lang.String” />
<property name=”crptfilename” column=”CRptFileName” type=”java.lang.String” />
</class></hibernate-mapping>
I’m using “native” as the id type for Hibernate (as that was the only one that worked when I did a little test app my first time through with Hibernate).
I am completely baffled here.
Riyad KallaMemberPlease post the schema for the tables, the problem is the mapper isn’t finding your ID field… also specify the driver you are using and version of MS SQL Server and Eclipse/MyEclipse please.
bradmMemberEclipse 3.1M7
The driver is com.microsoft.jdbc.sqlserver.SQLServerDriver, connecting to SQL Server 2000 sp3
The table looks like this:
[LetterTypeID] [int] IDENTITY (1, 1) NOT NULL ,
[LetterType] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[CRptFileName] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
Miles GilmourMemberI have exactly the same problem. I am using HSQLDB (v 1.7.3).
Here is the table definition:
cre@te table USERS(
ID INTEGER not null,
NAME VARCHAR(100),
PASSWORD VARCHAR(100))(I added the @ sign to ‘create’ as the forum software stopped me posting otherwise)
And when I use myeclipse (version below) to generate the mapping it does not define an id element (which is an invalid hbm XML file)
Version: 3.9.101
Build id: 20050508-4.0-Milestone-1
Riyad KallaMemberGuys I fired off all this info to our hibernate dev to have a look, hang tight.
support-jeffMemberI do not see Primary Key constraints defined in either case here. If IDENTITY is MSSQL for a PK definition, then the JDBC driver is probably not doing the right thing in communicating that via DatabaseMetaData.getPrimaryKeys(). Please take a look in the Table Info View in the DBX for these tables, select the Primary Key tab, and if nothing is shown there then the PK is not being recognised by the JDBC driver properly.
Miles GilmourMemberSurely you need to allow the option to manually set the key in your dialog box? It is entirely possible to have a database table without a primary key explicitly defined, but in the hibernate XML mapping files an id element is mandatory.
support-jeffMemberThe capability to define your own id mapping (either instead of or without a pk) is coming in the next milestone release.
bradmMemberIt would appear, then, that this problem is directly related to another one that has been around way too long IMHO: the inability of the Database Explorer to accuratly use Microsoft’s SQL Server JDBC driver (because of its 3-jar design: admittedly silly but there it is). See a related string of posts on this subject in this same forum. I sure hope this problem gets solved sooner rather than later. I have no other choice by SQL Server: it’s all I’m ever going to be able to work with around here.
Now I THOUGHT I had solved it by ignoring the Database Explorer’s implementation, selecting “New Driver”, and registering the 3 required jars manually. While I can now peruse SQL Server databases, it appears that my little hack isn’t all I need (though I admit I can’t understand why the id’s aren’t being seen correctly).
I sure wish I could use SQL Server without all this hassle folks. Really I do.
bradmMemberWell, I just created a System DSN connecting to the same table, and MyEclipse generated a perfectly good Hibernate mapping file, including the ID. So Jeff, you’re correct: the Database Explorer is not seeing the underlying meta data correctly. However, it DOES report that its sees my ID column as the primary key.
The Database Explorer just has got to be fixed to use MS SQL Server properly. If it’s not going to be, somebody let me know please.
Riyad KallaMemberbradm,
I’m forwarding your concerns and problems you had on to the team, we agree that a smoother “out of box” experience is one of our top priorities.
esrgMemberThis message has not been recovered.
Riyad KallaMemberThis message has not been recovered.
azorbaMemberI am evaluating the trial version, and I ran into the same problem with hibernate mapping generator for SQL server. The mapping does not get generated with jTDS and SQLserver drivers. It produces at the end an error message: An internal error occurred during “Generating Artifacts”. Were you guys able to solve this problem?
Regards,
Haris PecoMemberazorba,
Please, send us error log (Windows-Show View-Other-PDE Runtime-Error Log View) and if you can your schema script
Best
-
AuthorPosts