-->
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: List of String Class elements instead of own classes
PostPosted: Fri Apr 15, 2005 9:50 am 
Newbie

Joined: Fri Apr 15, 2005 9:22 am
Posts: 11
This might be a simple question but I have no idea how to face it.
I want a class to have a collection ( list ) of String elements.
Already did the same having own classes as elements since a bunch of tutorials show the e.g. as ...


Code:
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

    <class
        name="net.sourceforge.forum.Forum"
        table="TBL_FORUM"
        dynamic-update="false"
        dynamic-insert="false"
    >

        <id
            name="id"
            column="PK_CATEGORY_ID"
            type="java.lang.Long"
            unsaved-value="-1"
        >
            <generator class="native">
            </generator>
        </id>
       
        <bag
            name="threads"
            lazy="true"
            inverse="true"
            cascade="save-update"
        >

              <key
                  column="FK_FORUM_ID"
              />

              <one-to-many
                  class="net.sourceforge.forum.Thread"
              />
        </bag>

    </class>

</hibernate-mapping>



But what about if I want that also have a List of String elements ?
Should be something like ... ?


<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

<class
name="net.sourceforge.forum.Forum"
table="TBL_FORUM"
dynamic-update="false"
dynamic-insert="false"
>

<id
name="id"
column="PK_CATEGORY_ID"
type="java.lang.Long"
unsaved-value="-1"
>
<generator class="native">
</generator>
</id>

<bag
name="descriptions"
lazy="true"
inverse="true"
cascade="save-update"
>

<key
column="FK_FORUM_ID"
/>

<one-to-many
class="string"
/>
</bag>

</class>

</hibernate-mapping>

[/code]

Is that OK ?

Thanks !


Top
 Profile  
 
 Post subject: Re: List of String Class elements instead of own classes
PostPosted: Fri Apr 15, 2005 9:52 am 
Newbie

Joined: Fri Apr 15, 2005 9:22 am
Posts: 11
It's more readable...

jfreebsd wrote:
This might be a simple question but I have no idea how to face it.
I want a class to have a collection ( list ) of String elements.
Already did the same having own classes as elements since a bunch of tutorials show the e.g. as ...


Code:
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

    <class
        name="net.sourceforge.forum.Forum"
        table="TBL_FORUM"
        dynamic-update="false"
        dynamic-insert="false"
    >

        <id
            name="id"
            column="PK_CATEGORY_ID"
            type="java.lang.Long"
            unsaved-value="-1"
        >
            <generator class="native">
            </generator>
        </id>
       
        <bag
            name="threads"
            lazy="true"
            inverse="true"
            cascade="save-update"
        >

              <key
                  column="FK_FORUM_ID"
              />

              <one-to-many
                  class="net.sourceforge.forum.Thread"
              />
        </bag>

    </class>

</hibernate-mapping>



But what about if I want that also have a List of String elements ?
Should be something like ... ?

Code:
<!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

    <class
        name="net.sourceforge.forum.Forum"
        table="TBL_FORUM"
        dynamic-update="false"
        dynamic-insert="false"
    >

        <id
            name="id"
            column="PK_CATEGORY_ID"
            type="java.lang.Long"
            unsaved-value="-1"
        >
            <generator class="native">
            </generator>
        </id>
       
        <bag
            name="descriptions"
            lazy="true"
            inverse="true"
            cascade="save-update"
        >

              <key
                  column="FK_FORUM_ID"
              />

              <one-to-many
                  class="string"
              />
        </bag>

    </class>

</hibernate-mapping>



Is that OK ?

Thanks !


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.