-->
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.  [ 3 posts ] 
Author Message
 Post subject: Array of primitives generates MappingException
PostPosted: Wed Apr 28, 2004 3:13 pm 
Newbie

Joined: Mon Mar 29, 2004 1:08 pm
Posts: 10
What is the proper way to specify an array of primitives in an XML file for use in :
configuration.addFile(XMLFile)

that will not generate a message such as:

.net.sf.hibernate.MappingException: Could not interpret type: int[]

(Also, a similar message is generated for byte[], and other arrays of primitives).

Thanks

Charlie

**********************
Hibernate version: 2.1.2

Error generated before session.Factory.openSession() is called

I'm using postgresql 7.4


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 28, 2004 3:46 pm 
Pro
Pro

Joined: Tue Aug 26, 2003 1:24 pm
Posts: 213
Location: Richardson, TX
If each element of the array is gathered from a seperate record in a table, try <primitive-array>

Example:
Code:
<primitive-array name="foo">
  <key column="bar"/>
  <index column="idx"/>
  <element column="bas" type="byte"/>
</primitive-array>


Otherwise, if the whole array is stored in one field of each record, you need to define your own UserType. Some additional UserTypes for postgres are defined here: http://opensource.atlassian.com/projects/hibernate/browse/HB-450


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 28, 2004 11:25 pm 
Newbie

Joined: Mon Mar 29, 2004 1:08 pm
Posts: 10
The following code solves the problem:

private byte[] stuff;
...
/**
* @hibernate.property
* type="net.sf.hibernate.type.BinaryType"
public byte[] getStuff()
{
return this.stuff;
}

I also posted this to the sdoclet mailing list

Charlie


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.