annotations

Does Java Spring 3.0 MVC support annotation/attribute based client side validation like Asp.net MVC 2.0?

In Asp.Net MVC 2.0, at least in the beta, you could decoration your model classes with data annotation attributes and enable client side validation that leverages that criteria defined in your model data annotation attibutes. Is there anything similar for Java Spring MVC 3.0? Is it possible to inject a component into the response pipeli...

Hibernate. How can we set name of PK/FK using annotations?

We have hibernate-based system and customer wants to get human-readable names of PK and FK. In our project we use annotated entity classes. Is it renaming possible? ...

Dependency on Spring's annotations

I have annotated my classes with @Repository, @Resource, @Component, @Service annotations but these classes must run in 2 environments. The first environment is Spring 2.x based while the other has no spring at all. I'm sure the code will fail without the spring jars & I want to know ideas from you on how I can retain the annotations but...

Variable field in a constraint annotation

Hello, I need to create a custom constraint annotation which can access the value of another field of my bean. I'll use this annotation to validate the field because it depends on the value of the other but the way I define it the compiler says "The value for annotation attribute" of my field "must be a constant expression". I've defin...

How do i assert my exception message with JUNIT Test annotation ?

i have written a few junits with @Test annotation. If my test method throws a checked exception and if i want to assert the message along with the exception, is there a way to do so with JUNIT @Test annotation.AFAIK, Junit 4.7 doesnt provide this feature but does any future versions provide it. I know in .NET you can assert the message a...

Automatic "canShowCallOut" annotation IPHONE

Hi all, in wich way could i call the function that open automatically my annotation (with title, subtitle, calloutaccessorybutton, etc), rather than to touch on the annotation on the mapview? thanks in advance:) Mat ...

Grammar for Java's annotations

Is there a BNF or EBNF that describes the grammar for Java's annotations? ...

What java apis are there to help with annotation processing by using reflection?

Hi, I`m looking to start project that needs to process annotations. I was wondering what apis are available to help with reflection and annotation processing. I know theres Apache BeanUtils but are there any others? ...

I am getting an error with a oneToMany association when using annotations with gilead for hibernate through gwt

Hello Guys I'm using Gilead to persist my entities in my GWT project, im using hibernate annotations aswell. my problem is on my onetomany association.this is my User class that holds a reference to a list of FileLocations @Entity @Table(name = "yf_user_table") public class YFUser implements Serializable { @Id @GeneratedValue(strateg...

Java/Spring: Why won't Spring use the validator object I have configured?

I'm writing a web app with Java & Spring 2.5.6 and using annotations for bean validation. I can get the basic annotation validation working fine, and Spring will even call a custom Validator declared with @Validator on the target bean. But it always instantiates a brand new Validator object to do it. This is bad because the new valida...

Foreign key not stored in child entity (one-to-many)

Hi, I'm quite new to hibernate and have stumbled on this problem, which I can't find solution for. When persisting parent object (with one-to-many relationship with child), the foreign-key to this parent is not stored in child's table. My classes: Parent.java @javax.persistence.Table(name = "PARENT") @Entity public class PARENT { p...

Dynamic class annotation

Hi, I want to annotate a class dynamically to make it the more generic as possible: public class Test<T> { @XmlAttribute(name = dynamicvalue) T[] data; public Test(String dynamicvalue) { } } Is there any way to achieve something like this. TA ...

How do you use stereotype annotations in Spring 2.5.x?

When moving to Spring 2.5.x I found that it adds more stereotype annotations (on top of @Repository from 2.0): @Component, @Service and @Controller. How do you use them? Do you rely on implicit Spring support or you define custom stereotype specific functions/aspects/features? Or is it predominately for marking beans (compile time, conce...

Enums and Annotations

I want to use an Annotation in compile-safe form. To pass the value() to the Annotation i want to use the String representation of an enum. Is there a way to use @A with a value from enum E ? public class T { public enum E { a,b; } // C1: i want this, but it won't compile @A(E.a) void bar() { ...

Use Java Annotation not to run a method

Hi all: I've got a method in my class only for testing purpose : private void printOut(String msg, Object value) { System.out.println(msg + value); } It is a wrapper method for System.out.println(); So I hope, with the use of Annotation, I can choose not to run this method during productive environment while still keep those dia...

Spring MVC with annotations: how to beget that method always is called

hi, I'm currently migrating a project that is using Spring MVC without annotations to Spring MVC with annotations. This is causing less problems than expected but I did come across one issue. In my project I have set up an access mechanisme. Whether or not a User has access to a certain view depends on more than just the role of the Us...

Generating equals / hashcode / toString using annotation

I believe I read somewhere people generating equals / hashcode / toString methods during compile time (using APT) by identifying which fields should be part of the hash / equality test. I couldn't find anything like that on the web (I might have dreamed it ?) ... That could be done like that : public class Person { @Id @GeneratedValu...

Hibernate annotations cascading doesn't work

Hi all, I've decided to change hbm.xml style to annotations using hibernate. I had in my hbm.xml: <hibernate-mapping package="by.sokol.jpr.data"> <class name="Licence"> <id name="licenceId"> <generator class="native" /> </id> <many-to-one name="user" lazy="false" cascade="save-update" column="usr"/> </class> </hibernate-mappin...

Using a third party lib in an annotation processor with eclipse

Hi, maybe I do not see the wood for the trees, but I made an AnnotationProcessor and embedded it in eclipse. Works fine so far....but what if I need some 3rd party libs? I don't see any option to add those jars to the classpath. How/Where do I configure that in eclipse? Many many thanks! ...

Why does the definition of MyAnnotation need Documented, Inherited, Retention & RetentionPolicy?

What is the purpose of these java.lang.annotation imports in this code? Why are they needed to define MyAnnotation? import java.lang.annotation.Documented; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @Documented @Retention(RetentionPolicy.RUNTIME) @Inherited...