Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #7754

Re: Define Type at runtime

From Robert Klemme <shortcutter@googlemail.com>
Newsgroups comp.lang.java.programmer
Subject Re: Define Type at runtime
Date 2011-09-09 04:47 -0700
Organization http://groups.google.com
Message-ID <380f6934-90f0-4771-98f9-8287f6b442f1@dp9g2000vbb.googlegroups.com> (permalink)
References <4e678737$1@news.x-privat.org> <4e678ab5$0$13073$426a74cc@news.free.fr> <4e678d02$2@news.x-privat.org> <3d05f689-fd75-4ccd-8fd4-8e41b12f736a@a12g2000yqi.googlegroups.com> <4e69b9b9$1@news.x-privat.org>

Show all headers | View raw


On 9 Sep., 09:01, John <j...@yahoo.com> wrote:
> Il 08/09/2011 17:12, Robert Klemme ha scritto:
>
> > Just curious, how did you solve it?
>
> public void thisMethod(Object o){
>      ...
>      Root<?> myRoot = criteriaQuery.from(o.getClass());
>      ...
> }

I don't know your types but you could do something like

public <T> void thisMethod(T o){
     ...
     Root<T> myRoot = criteriaQuery.from(o.getClass());
}

If criteriaQuery.from() propagates types - which could be the case as
a quick Google search seems to indicate:
http://agoncal.wordpress.com/2010/05/28/jpa-2-0-criteria-api-with-maven-and-eclipselink/

Kind regards

robert

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Define Type at runtime John <john@yahoo.com> - 2011-09-07 17:01 +0200
  Re: Define Type at runtime Mayeul <mayeul.marguet@free.fr> - 2011-09-07 17:20 +0200
    Re: Define Type at runtime John <john@yahoo.com> - 2011-09-07 17:25 +0200
      Re: Define Type at runtime Robert Klemme <shortcutter@googlemail.com> - 2011-09-08 08:12 -0700
        Re: Define Type at runtime John <jonh@yahoo.com> - 2011-09-09 09:01 +0200
          Re: Define Type at runtime Robert Klemme <shortcutter@googlemail.com> - 2011-09-09 04:47 -0700
  Re: Define Type at runtime Lew <lewbloch@gmail.com> - 2011-09-08 09:32 -0700
    Re: Define Type at runtime BGB <cr88192@hotmail.com> - 2011-09-08 11:07 -0700
      Re: Define Type at runtime Lew <lewbloch@gmail.com> - 2011-09-08 11:25 -0700
        Re: Define Type at runtime BGB <cr88192@hotmail.com> - 2011-09-08 14:20 -0700
          Re: Define Type at runtime Lew <lewbloch@gmail.com> - 2011-09-08 14:35 -0700
            Re: Define Type at runtime BGB <cr88192@hotmail.com> - 2011-09-08 14:54 -0700
              Re: Define Type at runtime Lew <lewbloch@gmail.com> - 2011-09-08 17:10 -0700
                Re: Define Type at runtime BGB <cr88192@hotmail.com> - 2011-09-09 00:32 -0700
      Re: Define Type at runtime John <jonh@yahoo.com> - 2011-09-09 09:02 +0200

csiph-web