-->
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.  [ 4 posts ] 
Author Message
 Post subject: Want to allow duplicate rows in a composite-element set
PostPosted: Sun Dec 21, 2008 8:09 am 
Regular
Regular

Joined: Mon Mar 10, 2008 6:40 pm
Posts: 114
I have some logging tables that log simple things like when someone visits a particular webpage or whenever someone attempts to login. So for login attempts, the following <set> might be within a Person hibernate mapping:
Code:
<set name="loginAttempts" table="Login_Attempt">
    <key column="Person_Id"/>
    <composite-element class="com.treert.account.LoginAttempt">
        <property name="success" column="Success" type="boolean" not-null="true"/>
        <property name="loginDate" column="Login_Date" type="timestamp" not-null="true"/>
        <property name="ipAddress" column="IP_Address" type="int" length="32" not-null="true"/>
    </composite-element>
</set>

Maybe a hacker is trying a million passwords and so this table could have 2 rows with exactly the same entries. i don't want the hacker to get a MySQL exception! :), well maybe this example isn't the greatest, but other parts of my code with exactly the same situation are important for me to log duplicate rows.

How can I tell hibernate to allow 2 rows with the same data? I understand the limitations of then being able to update or delete these rows, this is purely for logging purposes. I'll read the rows in bulk.[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 22, 2008 4:11 pm 
Newbie

Joined: Mon Dec 22, 2008 3:49 pm
Posts: 2
This prevention of duplicates has to do set. Set by definition cannot have duplicate elements. Use a bag instead. It can allow duplicates


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 23, 2008 2:34 pm 
Regular
Regular

Joined: Mon Mar 10, 2008 6:40 pm
Posts: 114
Thanks, I'll look into bags. I read a brief mention of bags, but had trouble finding the documentation on it... I'll look harder now.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 24, 2008 3:41 pm 
Regular
Regular

Joined: Mon Mar 10, 2008 6:40 pm
Posts: 114
Why is there almost no documentation about bags?? Aren't bags a pretty important concept in database operations? Is there a better way to log operations? Even the Bag class javadoc (http://www.hibernate.org/hib_docs/v3/api/org/hibernate/mapping/Bag.html) is completely void of any comments... The author is listed as Gavin King who, as I understand, left the hibernate project a long time ago.

Is hibernate still being actively maintained? I'm a bit concerned relying so much on a framework that isn't moving forward and is starting to have some serious limitations (like so many uses of int without an option for long when servers today are more than capable of using values > 2.1billion).


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