-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Using collection with Axis web service
PostPosted: Tue Nov 21, 2006 4:01 am 
Newbie

Joined: Thu Oct 19, 2006 7:53 pm
Posts: 10
I am adding Axis 1.4 web services to a working Struts application.
In the Property class file auto-generated from WSDL, the references to java.util.Set are changed to java.lang.Object[].

Set rooms = property.getRooms();

generates error - Type mismatch: cannot convert from Object [] to Set;

Any suggestions or pointers to examples using Axis and Hibernate would be greatly appreciated.

Hibernate version: 3.2

Mapping documents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping
schema="hfydb"
default-cascade="save-update, delete"
auto-import="true"
package="com.hfy.domain"
default-lazy="false">

<class
name="Property"
table="property"
>

<id
name="id"
type="java.lang.Integer"
column="property_id"
>
<generator class="increment" />
</id>

<many-to-one name="office" class="Office" column="office_id" cascade="none" />
<many-to-one name="style" class="Type" column="type_id" cascade="none" />
<many-to-one name="address" class="Address" column="address_id" cascade="all" />

<!-- one-to-many association between Property and Room -->
<!-- http://www.hibernate.org/hib_docs/v3/re ... child.html
the Room entity is managing the FK property_id link,
the inverse attribute tells the collection not to update the link.
all-delete-orphan: a Child can't really exist without its parent
on-delete="cascade" don't delete Room collection prior to removing a Property
CONSTRAINT `FK_PROPERTY_ID` FOREIGN KEY (`PROPERTY_ID`) REFERENCES `property` (`PROPERTY_ID`) ON DELETE CASCADE
the database deletes the rooms if the referenced property is deleted
http://forum.hibernate.org/viewtopic.ph ... aint+fails
-->
<set name="rooms" table="room" inverse="true" cascade="all-delete-orphan" >
<key column="property_id" on-delete="cascade"/>
<one-to-many class="Room" />
</set>

<property
name="appearOnPublic"
type="java.lang.Boolean"
column="public_access"
/>

<property
name="price"
type="java.lang.Integer"
column="price"
/>

</class>
</hibernate-mapping>

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping
schema="hfydb"
default-cascade="save-update, delete"
auto-import="true"
package="com.hfy.domain"
default-lazy="false">

<class
name="Room"
table="room"
>

<id
name="id"
type="java.lang.Integer"
column="room_id"
>
<generator class="increment" />
</id>

<!--
<property
name="property"
type="domain.Property"
column="property_id"
/>
-->
<!-- Make FK property_id part of the mapping -->
<many-to-one name="property" class="Property" column="property_id" not-null="true" />
<many-to-one name="type" class="Type" column="type_id" cascade="none" />

<property
name="name"
type="java.lang.String"
column="name"
not-null="true"
length="30"
/>

</class>
</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:
MySQL

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 21, 2006 10:40 am 
Beginner
Beginner

Joined: Fri Apr 15, 2005 3:30 pm
Posts: 46
Location: Fortaleza, Brazil
First of all I'm not sure why your WSDL is producing a mapping to object[] instead of yourClass[] . Anyways, this is a matter of simple java ... I do stuff like this with Axis 1.x and more recently with Axis2 all the time:

Object [] objectArray = property.getRooms()
List objectList = Arrays.asList(objectArray);
Set arraySet = new HashSet (objectList);

There's your conversion. I suspect though that you'll either need generics to match the expected hibernate Set or put the object array in a for loop and populate it manually.

HTH,
Robert


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.