| Author |
Message |
|
|
Post subject: [Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index
Posted: Jul 24, 2006 - 08:39 PM
|
|
Registered Member


Joined: Sep 11, 2005
Posts: 28
|
|
Hi,
I have a simple pair of parent and child classes and their mapping files.
I have a java program that puts a parent object and some children in the database. There is no problem with this.
I have another java program (public class TestReadingObjects), shown below, that retrieves the objects (parent with its children) from the database. The two hbm.xml files are also shown below.
When I execute these programs using a Microsoft SQL Server database, the objects are put in the database without problems, but the program below results in the error "[Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index" followed by the error "could not initialize a collection: [javaClasses.Parent.children#1]".
When I execute these programs using a MySQL database, the objects are put in the database without problems, and the program below (public class TestReadingObjects), reads them without problems.
From comments I found on the internet, it seems that the Dialect file for Microsoft SQL Server might be causing the problem. I am using the dialect file received with MyEclipse M2.
Can anyone suggest how I can get past this problem? I will have to use Microsoft SQL Server in my final completed program as the system has to integrate with an existing SQL Server database.
Your help will be appreciated.
Mike King
program and two mapping files are below
----------------------------------------------------------------------
package testHarnesses;
import java.util.Iterator;
import java.util.List;
import javaClasses.Child;
import javaClasses.Parent;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import factoryClass.HibernateSessionFactory;
public class TestReadingObjects {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Session s = HibernateSessionFactory.getCurrentSession();
Transaction t = s.beginTransaction();
try {
Query q = s.createQuery("from Parent ");
List lis = q.list();
Iterator i = lis.iterator();
while (i.hasNext()) {
Parent element = (Parent) i.next();
System.out.println(element.getParentName());
Iterator j = element.getChildren().iterator();
while (j.hasNext()) {
Child child = (Child) j.next();
System.out.println(child.getChildName());
}
}
t.commit();
} catch (HibernateException e) {
// TODO Auto-generated catch block
t.rollback();
e.printStackTrace();
} finally {
s.close();
}
}
}
<?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">
<hibernate-mapping
>
<class
name="javaClasses.Parent"
table="DataArchitecture1.dbo.MapIt_Test_Parent_Table"
lazy="false"
>
<id
name="id"
column="ParentID"
type="java.lang.Integer"
>
<generator class="increment">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-MapItClassifierMap.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
<property
name="parentName"
type="java.lang.String"
column="Parent_Name"
/>
<set name="children" inverse="true" lazy="false" cascade="save-update">
<key column="ParentID" />
<one-to-many class="javaClasses.Child"/>
</set>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-MapItClassifierMap.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping>
<?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">
<hibernate-mapping
>
<class
name="javaClasses.Child"
table="DataArchitecture1.dbo.MapIt_Test_Child_Table"
lazy="false"
>
<id
name="id"
column="ChildID"
type="java.lang.Integer"
>
<generator class="increment">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-MapItClassifierMap.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>
<property
name="childName"
type="java.lang.String"
column="Child_Name"
/>
<many-to-one name="parent" class="javaClasses.Parent" column="ParentID" lazy="false">
</many-to-one>
<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-MapItClassifierMap.xml
containing the additional properties and place it in your merge dir.
-->
</class>
</hibernate-mapping> |
|
|
| |
|
|
|
 |
|
|
Post subject:
Posted: Jul 24, 2006 - 10:43 PM
|
|
Registered Member

Joined: Jan 06, 2004
Posts: 23855
|
|
I've asked one of our developers to have a look. |
_________________ Riyad
MyEclipse Support
|
| |
|
|
|
 |
|
|
Post subject:
Posted: Jul 24, 2006 - 11:07 PM
|
|
Moderator


Joined: Feb 03, 2006
Posts: 1117
|
|
Mike,
Please send your database and jdbc version and (if it possible) schema script for your tables
I will try reproduce your problems
Thanks
Peco |
|
|
| |
|
|
|
 |
|
|
Post subject:
Posted: Jul 24, 2006 - 11:09 PM
|
|
Moderator


Joined: Feb 03, 2006
Posts: 1117
|
|
... and log file , please (windows-Show view-Other-PDE Runtime-Error Log view)
Thanks |
|
|
| |
|
|
|
 |
|
|
Post subject:
Posted: Jul 25, 2006 - 12:20 PM
|
|
Registered Member


Joined: Sep 11, 2005
Posts: 28
|
|
Thanks RKalla and snpe. I have sent a private message back with the information you asked for. I made it private to be able to attach a file. |
|
|
| |
|
|
|
 |
|
|
Post subject:
Posted: Mar 13, 2010 - 05:18 PM
|
|
Joined: Jun 07, 2009
Posts: 6
|
|
There are a lot of tools,which work with sql files. But one of them liked me and I downloaded it from a soft blog - download database recovery mdf. The tool solved my issue for seconds and absolutely free as far as I remember. Moreover the application showed me how it provides evaluation services for any database in Microsoft SQL format that cannot be opened normally; restore Microsoft SQL files. |
|
|
| |
|
|
|
 |
|
|