-->
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.  [ 7 posts ] 
Author Message
 Post subject: no success - xDoclet with map/composite-index and <any>
PostPosted: Tue Sep 30, 2003 7:13 am 
Newbie

Joined: Mon Sep 22, 2003 5:43 am
Posts: 15
Hi Everybody,

I have two problems recreating my mapping in xDoclet.

The first:

I


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 30, 2003 7:52 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
I'm not sure what your problem is. The mapping looks fine.


Top
 Profile  
 
 Post subject: Mapping OK -- xDoclet BAD
PostPosted: Tue Sep 30, 2003 8:50 am 
Newbie

Joined: Mon Sep 22, 2003 5:43 am
Posts: 15
Hi Gavin,

btw: XDoclet: 1.2b4

Thanks for the reply, I'll try and elaborate.
The mapping I've done by hand and it works really well.
Now I'm implementing xDoclet to create my mapping files as the project is growing fast and it's becoming dificult to maintain one global mapping file.

I can't recreate my "by-hand" mapping using xDoclet.

Here are my two java classes, I want the created hbm to be the same as the excerpt in the first part of my message.

Full Listing of Composite ID class
----------------------------------------------------
package com.xxx.model.xData.text;

/**
* To identify text instances in a MAP
* NOT PERSISTED AS A FIRST RANK CLASS
* @author bregrada
* @date 11-Jun-2003
* @time 12:53:55
*
*/
public class TextId {
private String key;
private String locale;

public TextId(){

}
public TextId(String key,String locale) {
setKey(key);
setLocale(locale);
}

/**
* @hibernate.property
* column="ik_key" length="20"
*/
public String getKey() {
return key;
}


public void setKey(String key) {
if (key.length()>20) {
this.key = key.substring(0,20);
} else {
this.key = key;
}
}

/**
* @hibernate.property
* column="ik_locale" length="20"
*/
public String getLocale() {
return locale;
}


public void setLocale(String locale) {
if (locale.length()>20) {
this.locale = locale.substring(0,20);
} else {
this.locale = locale;
}
}

public boolean equals(Object o) {
if (this == o)
return true;
if (!(o instanceof TextId))
return false;

final TextId textId = (TextId) o;

if (!key.equals(textId.key))
return false;
if (!locale.equals(textId.locale))
return false;

return true;
}

public int hashCode() {
int result;
result = key.hashCode();
result = 29 * result + locale.hashCode();
return result;
}
}
----------------------------------------------------
Part of "main" class that has a map of Composite Id's and String objects
----------------------------------------------------

private Map names; //initialised in the constructor

/**
* ---No hibernate mapping, this is done by an include at the moment---
* @hibernate.map
* table="ik_Text_Instance"
* @hibernate.collection-key
* column="ik_objectId"
* @hibernate.collection-index
* class="com.ikusi.xsip.model.xsipData.text.TextId"
* @hibernate.collection-element
* type="string"
* column="ik_Text"
*/
public Map getNames() {
return names;
}

public void setNames(Map names) {
this.names = names;
}

-------------------------------------------------
I feel that I ought to be using @hibernate.key-properties and @hibernate.composite-index javadoc tags, but I can't find any doco on these apart from the odd message on the development mailing list that these may or may not be implemented (dated Dec 2002)
--------------------------------------------------

Generated file as follows:

--------------------------------
<map
name="names"
table="ik_Text_Instance"
lazy="false"
sort="unsorted"
inverse="false"
cascade="none"
>

<key
column="ik_objectId"
/>

<index
column=""
/>

<element
column="ik_Text"
type="string"
not-null="false"
unique="false"
/>

</map>
-----------------------------------------------
Is the solution to continue to use a "merge" document?

Thanks,

Dan


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 30, 2003 9:18 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
ah, I'm not sure of the XDoclet module supports composite-index ... you might need to use a merge file for this.


Top
 Profile  
 
 Post subject: No problem
PostPosted: Tue Sep 30, 2003 9:28 am 
Newbie

Joined: Mon Sep 22, 2003 5:43 am
Posts: 15
Hi Gavin,

Ok Fine.

It seems that xDoclet doesn't support:

<composite-index>

or

<any>

But it seems easily solved with the use of a "merge" document.

Thanks,

Dan


Top
 Profile  
 
 Post subject: composite-index accepted by xdoclet
PostPosted: Thu Jul 28, 2005 9:24 am 
Newbie

Joined: Thu Jul 28, 2005 8:52 am
Posts: 1
Hello

I am a newbie with Hibernate and I wanted to use the "composite-index" with xdoclet.
I have finally managed to use it although the "composite-index" tag is not mentionned by the xdoclet list :

http://xdoclet.sourceforge.net/xdoclet/ ... -tags.html

But as it is said there : http://opensource.atlassian.com/project ... se/XDT-830

Xdoclet now supports this tag :

@hibernate.collection-composite-index
class="NameOfClass"

Here is my example :

I use a Map which contains customized "Preference" objects and the key is a "PreferencesKey" object with 2 properties : the string "language" and a integer "key_id" managed by myself (it is the simplest way I have found to have a list of "Preference" objets in my Map without using nested collections that are not supported by Hibernate).

Now, the xdoclet tags with "composite-index" are :

/**
* @hibernate.map
* table="XXXXXXXXX"
* lazy="true"
* cascade="all"
* @hibernate.collection-key
* column="my_object_id"
* @hibernate.collection-composite-index
* class="XXXXX.PreferencesKey"
* @hibernate.collection-many-to-many
* class="XXXXX.Preference"
* column="preference_id"
*/

I also have to describe the PreferencesKey class:

/**
* id manipulation
* @hibernate.property
* column="key_id"
*/
public int getId(){
return this.id;
}

public void setId(int id){
this.id = id;
}

/**
* langue manipulation
* @hibernate.property
* column="language"
*/
public String getLangue(){
return this.langue;
}

public void setLangue(String langue){
this.langue = langue;
}

And it works : xdoclet generates the right hbm.xml file :

[...]
<map
name="preferencesMap"
table="XXXXXXXXXX"
lazy="true"
sort="unsorted"
cascade="all">

<key column="my_object_id">
</key>

<composite-index
class="XXXX.PreferencesKey">
<key-property
name="id"
type="int"
column="key_id"/>

<key-property
name="langue"
type="java.lang.String"
column="language"/>

</composite-index>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 28, 2005 8:55 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
HIbernate support has been recently improved with a focus on H3. Check out the CVS version (or the 1.3.x release once it is out).


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