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: Unique combination of fields
PostPosted: Sun Apr 08, 2007 7:14 am 
Newbie

Joined: Thu Dec 23, 2004 7:23 am
Posts: 12
Location: Melbourne
Hi,

I have two domain classes, Item and Feed, and each Feed might have many items and each item only belongs to one feed.

Here's the definition of Item:

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

<hibernate-mapping package="com.behrangsa.data">

    <class name="Item" table="item">

        <id name="id" column="id">
            <generator class="native" />
        </id>

        <property name="title" length="50" not-null="true"/>
        <property name="link" length="255" not-null="true" />       

        <many-to-one
            name="feed"
            column="feed_id"
            not-null="true" />

    </class>

</hibernate-mapping>


The many-to-one relation adds a feed_id column to the item table generated for the Item class. How can I make the combination of feed_id and link unique?

Thanks in advance,
Behi

_________________
http://www.koderblogz.com


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 08, 2007 7:29 am 
Newbie

Joined: Thu Dec 23, 2004 7:23 am
Posts: 12
Location: Melbourne
Solved ;)

-Behi

_________________
http://www.koderblogz.com


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.