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


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

Re: How do I figure out what class method is annotated with @Id?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From markspace <-@.>
Newsgroups comp.lang.java.programmer
Subject Re: How do I figure out what class method is annotated with @Id?
Date Thu, 22 Sep 2011 11:49:50 -0700
Organization A noiseless patient Spider
Lines 28
Message-ID <j5g00i$n2i$1@dont-email.me> (permalink)
References <46e27630-0633-49fb-975b-a4e78d787655@v7g2000yqk.googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Thu, 22 Sep 2011 18:49:54 +0000 (UTC)
Injection-Info mx04.eternal-september.org; posting-host="XjIWM99mD7Ijfdu600oVPA"; logging-data="23634"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+LdDZKgiZwxGOqkWsO37nC5yzOCVMj7CA="
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko/20110902 Thunderbird/6.0.2
In-Reply-To <46e27630-0633-49fb-975b-a4e78d787655@v7g2000yqk.googlegroups.com>
Cancel-Lock sha1:B0gDioK4xShHDQJhceBOtDv1N3I=
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:8214

Show key headers only | View raw


On 9/22/2011 11:42 AM, laredotornado wrote:
> Hi,
>
> I'm using Java 6 with the latest version of Hibernate.  I have several
> POJOs, all of which have exactly one method annotated with
> "javax.persistence.Id".  For example, one class has ...
>
>     @Id
>     @Column(name="ID")
>     public Integer getID() {
>        return ID;
>     }
>
> Given a java.lang.Class, how do I figure out what method is annotated
> with the "@Id" annotation?  Thanks, - Dave


I think my first question is "Why do you want to do that?"  It sounds 
like a very very bad idea.  You shouldn't be messing around with those 
entities at all, let the persistence layer handle that.  Your access to 
"id" should come from some higher level of business logic.

If you must (not recommending):
<http://download.oracle.com/javase/tutorial/reflect/index.html>

<http://download.oracle.com/javase/6/docs/api/java/lang/Class.html#getAnnotations%28%29>

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


Thread

How do I figure out what class method is annotated with @Id? laredotornado <laredotornado@zipmail.com> - 2011-09-22 11:42 -0700
  Re: How do I figure out what class method is annotated with @Id? markspace <-@.> - 2011-09-22 11:49 -0700
  Re: How do I figure out what class method is annotated with @Id? Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-09-22 14:54 -0700
    Re: How do I figure out what class method is annotated with @Id? markspace <-@.> - 2011-09-22 15:30 -0700
      Re: How do I figure out what class method is annotated with @Id? Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2011-09-22 16:11 -0700

csiph-web