Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
MikeKing
Post subject: [Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index  PostPosted: Jul 24, 2006 - 08:39 PM
Registered Member
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>
 
 View user's profile Send private message  
Reply with quote Back to top
support-rkalla
Post subject:   PostPosted: Jul 24, 2006 - 10:43 PM
Registered Member
Registered Member


Joined: Jan 06, 2004
Posts: 23855

I've asked one of our developers to have a look.

_________________
Riyad
MyEclipse Support
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
support-snpe
Post subject:   PostPosted: Jul 24, 2006 - 11:07 PM
Moderator
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
 
 View user's profile Send private message  
Reply with quote Back to top
support-snpe
Post subject:   PostPosted: Jul 24, 2006 - 11:09 PM
Moderator
Moderator


Joined: Feb 03, 2006
Posts: 1117

... and log file , please (windows-Show view-Other-PDE Runtime-Error Log view)

Thanks
 
 View user's profile Send private message  
Reply with quote Back to top
MikeKing
Post subject:   PostPosted: Jul 25, 2006 - 12:20 PM
Registered Member
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.
 
 View user's profile Send private message  
Reply with quote Back to top
zlatan24
Post subject:   PostPosted: 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.
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits