-->
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.  [ 3 posts ] 
Author Message
 Post subject: Criteria Search of @Lob byte[]
PostPosted: Wed Jul 07, 2010 8:34 am 
Newbie

Joined: Sat Sep 12, 2009 12:50 pm
Posts: 6
Hi,

I try to do a criteria search on a byte[] field persisted in mysql with @Lob annotation.
I always get an empty result :( Is there a special way for submitting binary data to the criteria api?

The byte[] field is persisting a mac address (6 bytes)

Here the example:

======== annotated class ==========
public class DhcpEntry {

@Id
@GeneratedValue
private long id;

@Lob
@Column(length=6)
private byte[] bootMac;
...
}
================================

== Entry in mysql is persisted ok! (this is an export) ==

INSERT INTO `netboot_DhcpEntry` (`id`, `bootMac`, ..) VALUES (1, 0x002257a078e0, ..);
=================================

== Search is done this way ==

mac is byte[] and filled up right: mac[0] = 0x00; mac[1] = 0x22; mac[2] = 0x57,...

..
crit.add(Restrictions.eq("bootMac", mac));
..

I already tried Restrictions.like but nothing found :(
=======================


Thanks for any help!


Top
 Profile  
 
 Post subject: Re: Criteria Search of @Lob byte[]
PostPosted: Wed Jul 07, 2010 9:16 am 
Newbie

Joined: Wed Sep 24, 2008 12:48 pm
Posts: 6
muffinman, you'll get lots of problems trying to query lobs and clobs (most DBs don't support this). A healthy suggestion: Change the type to be a string, and save the mac as an HEX string.


Top
 Profile  
 
 Post subject: Re: Criteria Search of @Lob byte[]
PostPosted: Wed Jul 07, 2010 9:17 am 
Newbie

Joined: Wed Jul 07, 2010 5:09 am
Posts: 2
Dont know if this would help but still see if you can try.

Code:
crit.add(Expression.sql("DBMS_LOB.COMPARE(COLUMN_NAME,mac)=0"));


Cheers!!!

Also what augusto.rodriguez says is true.. even i faced issues with it


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