-->
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: hibernate criteria for ipaddress subnet
PostPosted: Wed Jul 23, 2008 1:09 am 
Newbie

Joined: Mon Jul 14, 2008 7:38 pm
Posts: 2
hi everyone,

I have a situation where i have to search in database for an IP_ADDRESS column, which contains 1000's of ipaddress. An example of ip address is 157.198.156.45 in this ip address the third octet is called C subnet.

So, the condition here is that i have to write a hibernate criteria so, that we have to count the no.of C subnets and their corresponding ipaddress.

for example: set of ip address: 1.2.3.4, 1.2.3.6, 1.2.3.8, 1.8.3.7, 1.0.5.8, 2.3.5.9, 8.9.7.9

if this is the column name then the output should be:

C subnets no.of corresponding address
------------- --------------------------------
3 --------------> 4
5 --------------> 2
7 --------------> 1


thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 25, 2008 3:04 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Maybe you could just use a very flexible MatchMode?

Quote:
static MatchMode ANYWHERE
Match the pattern anywhere in the string
static MatchMode END
Match the end of the string to the pattern
static MatchMode EXACT
Match the entire string to the pattern
static MatchMode START
Match the start of the string to the pattern


Then create a sample object with the octet you're searching for in the example class. Here's a code snippet from the Hibernate tutorials on my website:

Code:
User user = new User();
user.setPassword("PASS");
Example example = Example.create(user);
example.enableLike(MatchMode.ANYWHERE);
example.ignoreCase();
example.excludeProperty("verified");


How to Use the Criteria API in you Hibernate Applications: A Simple Tutorial

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


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.