annotations

Java reflection (and annotations): bean.class is empty

I jave a simple Java bean with 4 attributes, getter/setter, and some overided methods like toString, equals and hashCode. Above every Attribute is a custom Annotation: import java.lang.annotation.*; import java.lang.annotation.RetentionPolicy; @Target(ElementType.FIELD) @Retention( RetentionPolicy.RUNTIME ) public @interface DAOProper...

Hibernate Mapped Superclass relationships and overriding

I have an abstract MappedSuperClass, Participant, which is extended by three kinds of 'Participant'. Each one then uses its own kind of 'Project', also an abstract MappedSuperClass. However, I want the base class to know about Projects so I can write generic code to interact with Participants. How do I specify this using Hibernate annota...

Spring 3 Annotations - HibernateDaoSupport - Repository Requires Session Factory

I am getting an exception saying : java.lang.IllegalArgumentException: 'sessionFactory' or 'hibernateTemplate' is required when trying to use the @Repository annotation on a HibernateDaoSupport class. The error message is straightforward, in order to create the Repository it needs a sessionFactory. However,I have defined a s...

Open a file with specific page from an anchor tag.

Hi all, I am trying to open a specific page in a file from an anchor tag(<a href=""></a>). The anchor tag is in a xls file.When i tried doing this i am able specify find the specified page but when i pass a parameter i am nt able to find the location of the page. Can anyone help me in this pls. Thanks ...

Generating getters/setters in Java (again)

I'm considering the approaches to write class MyClass { @Get @Set protected int aValue; } and then, automatically, generate get_aValue() and set_AValue() methods for the class. I've found these possibilities: 1a) At compile time. Use an annotation processor for separately processing MyClass.java, then write a new MyClass.j...

Using annotations to return custom results in struts2

I know that you can return custom objects using struts2 by specifying a declaration in your struts.xml file. I've done that, gotten that to work. What I want to do is move away from that, and accomplish the same thing via annotations. If I have an action that is going to return a custom result type I would like to be able to do it. ...

Are annotations some sort of DSL in Java?

After a bunch of XML config files, I've seen Java moving to Annotation based configurations. Are annotations playing the role of DSL here? Is it because the static nature of Java? I'm thinking in Ruby which doesn't have ( afaik ) things like that. Is it because Ruby has good metaprogramming capabilities? Are there alternatives ( I m...

Are Java meta-annotations available at runtime?

I have created a meta-annotation and applied it to an annotation but can't find any way to find what meta-annotations are associated with the annotation at runtime. Is this actually supported in JDK 6? E.g.: /** * Meta-annotation for other annotations declaring them to be "filter" annotations */ @Target(ElementType.ANNOTATION_TYPE) ...

How to create annotation-configured beans with an existing instance of @Configuration?

Assume we have a simple @Configuration: @Configuration public class FooBarConfiguration { @Bean public Foo createFoo() { return new FooImpl(); } @Bean @Autowired public Bar createBar(Foo foo) { return new BarImpl(foo); } } This class can be used with AnnotationConfigApplicationContext to p...

ASP.NET MVC 2 - How to override an annotation for a single controller action?

I have a BaseController that all Controllers inherit from. The CaseController has the [Authorize] annotation, so that all controllers require authorization. But I've just realized that one single controller action must not require authorization. How can I turn off [Authorize] for just that one controller action? using System.Web.Mvc;...

MapKit How to pass managedObject from mapView to mapDetailView

I am trying to pass a managedObject from a mapView with multiple annotation to a mapDetailView with only one annotation of the managedObject passed. This works great in a tableView to mapDetaiView. Any help would be appreciated. My code ... - (void)viewDidLoad { [super viewDidLoad]; if (self.managedObjectContext == nil) { self.man...

iPhone MapKit, get location of the dropped pin.

I'm creating an iPhone application that gets the user to drop a pin where ever they want. After they drop the pin the user then clicks on it and i want it to show the location of the pin in the call out as the subtitle. I have the mapview set up as well as the call out working and also the user is able to drop the pin where ever they w...

spring controller call from javascript. annotations with spring

Is it possible to call a spring controller from javascript included in a jsp? I'm trying to call it like this: form.action='${pageContext.request.contextPath}/spring/myController'; I can see that the control passes throught the lines, but nothing is happening. Also I get messages like get or post is not supported. when I submit the ...

Hibernate - a different object with the same identifier value was already associated with the session

After changing the @id of a Entity from @Id private int getId(){ return this.id; } to @Id private String getLogin(){ return this.login; } I get the error: a different object with the same identifier value was already associated with the session In the webapplication isn't changed anything. A read the entity and then ch...

How to restrict the usage of a Java public class outside of its Jar?

I'd like to be able to annotate a public class/interface in Java as @NonPublic, which would mean This interface is only to be used within this project, it is not part of the public API that this project exports. This is common for projects that are composed of several jar files. Not all public classes/interfaces are meant to really be p...

Spring Validation Annotations Order

Hi, I want to ask is it possible to set explicitly the validation order in Spring. I mean, I have this command object: public class UserData { @NotBlank private String newPassword; @NotBlank private String confirmPassword; @Email(applyIf="email is not blank") @NotBlank private String email; @NotBlank private String firstNam...

Is there a way to pass a Java annotation as a parameter?

Guys is there a way to pass a Annotation as a direct parameter (rather by doing all the reflection overhead)? For example in the following code, I have a annotation Number that holds a int value, I want to pass as a parameter to the addImpl method, how can I do that (other than by reflection)? Code Snippet: @Retention(RetentionPolicy.R...

Hibernate - encrypted reference by relations on usernames

I was wondering if my idea is possible with hibernate. What I want is that there is one table with usernames and every table wich has a reference to this table has the username encrypted in a column. So the username doesn't stand in normal text but encrypted in every table which have a reference to the user table. So I need something...

@autowired @qualifier pointing to a service in a jar file application

I am using another application's service,since everything is already made and done. My application is to use the interface class inside the application jar. but something seem to be wrong when this code is called. BeanFactory factory = new ClassPathXmlApplicationContext( "/Context-Controller.xml"); even if my Context-Controller.xml h...

How can I create an annotation processor that processes a Local Variable?

I'm trying to create an annotation for a local variable. I know that I can't retain the annotation in the generated bytecode, but I should be able to have access to the information at compile time by doing something like this: @Target({ElementType.LOCAL_VARIABLE}) @Retention(RetentionPolicy.SOURCE) public @interface Junk { String valu...