Tuesday 15 May 2012

syntax for java list interface used by hibernate in java? -



syntax for java list interface used by hibernate in java? -

sorry if duplicate question , if happen have reply or other post, please allow me know , delete this. however, have tried find documentation , reply this, if can explain code me, highly appreciate. dont know if right construction of question.

i have class named: persondao.java next code:

public interface personadao { **public list<person> showperson();** public void insertperson (person person); }

second, have class implements interface follows:

public class personadaoimplement implements personadao { @override public list<person> showpersonas() { session session = null; list<person> lista = null; seek { session = hibernateutil.getsessionfactory().opensession(); query query = session.createquery("from person"); lista = (list<person>) query.list(); } grab (hibernateexception e) { system.out.println(e.getmessage()); } { if (session != null) { session.close(); } } homecoming lista; }//end

so proper way or syntax when declaring method within interface class?

as can see got public list showperson(); its: [access modifier] list , ?????

im asking because using list, have seen many examples using "proper way" next line:

list<object> list = new arraylist<object>();

but in persondao.java class has next line:

public list<person> showperson();

what 1st question>>>>> right way, syntax , illustration please?

im totally confused cause method next not there in other declaration, type of utility of what?

of after list<person> [here goes method want] ...........> valid? or used on interfaces? there special type declaring list in interface?

im confused how utilize type of list, can explain me please?

regards,

(i assumming issue related method overloading)

when java sees method phone call "tracks down" right method method name , arguments (the number of arguments , types).

your interface declares next method:

public list<person> showperson()

its called showperson , has no args.

your class states overrides method called showpersonas:

@override public list<person> showpersonas() {...}

which unknown method.

see more info overloading methods here

java hibernate list methods collections

No comments:

Post a Comment