-->
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.  [ 6 posts ] 
Author Message
 Post subject: Mistake in documentation for Chapter 15. Criteria Queries?
PostPosted: Fri Mar 11, 2005 11:20 am 
Newbie

Joined: Wed Mar 09, 2005 2:46 pm
Posts: 8
The fourth code example reads:

...
.add( Restrictions.in( "name", new String[] { "Fritz", "Izi", "Pk" } ) )
...

which seems strange since the API is:

Restrictions.in( String, Object[] )

and String[] in Java is not a subtype of Object[]


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 11, 2005 11:28 am 
Newbie

Joined: Wed Mar 09, 2005 2:46 pm
Posts: 8
15.4 Associations

have a parenthesis missing in:

Code:
List cats = sess.createCriteria(Cat.class)
    .add( Restrictions.like("name", "F%")
    .createCriteria("kittens")
        .add( Restrictions.like("name", "F%")
    .list();

[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 11, 2005 7:42 pm 
Regular
Regular

Joined: Fri Mar 04, 2005 1:33 pm
Posts: 65
Location: U.K.
If you look into Java API, you will see Sting is inherited from an Object ...


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 12, 2005 4:45 am 
Newbie

Joined: Wed Mar 09, 2005 2:46 pm
Posts: 8
I think you'll find that:

String != String[]

and

Object != Object[]

and despite String being a subtype of Object,

String[] is not a subtype of Object[]


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 12, 2005 5:09 am 
Regular
Regular

Joined: Tue Mar 01, 2005 2:35 pm
Posts: 60
In Java, arrays are treated like objects, but deep down they are just C-style arrays. They inherit from Object sure, but you can't extend them and they really don't have methods. You can think of them as implementing generics, only before it was actually posible in Java. As if there were an array class implemented as such:

class Array<T> ...

So, carrying on the example, a method expecting an Array<Object> would certainly accept an Array<String>. That's the case here.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 12, 2005 5:22 am 
Newbie

Joined: Wed Mar 09, 2005 2:46 pm
Posts: 8
ok I concede... I'm wrong.


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