annotations

Execute code before and after method?

In the service layer I have a classes that look something like: class MyService { public doSomething() { TelnetSession session = new TelnetSession(); session.open("username", "password"); session.execute("blah"); session.close(); } } In many classes I have to declare and open session and then at...

Add random annotations to MKMapView

I need to add 'xx' amout of random annotations to an MKMapView, within a certain range of the user's current location. But i can't figure out how to do it. Can some of you help me? ...

Modelling a triple-join column in Hibernate an alternative way

Hi! I have a problem with mapping a triple join table as a map with Hibernate using annotations. I have 3 tables: project, group, role and triple join table project_group_role with columns project_id, group_id, role_id (the primary key is a pair of project_id and group_id). Database structure is given strictly from supervisor, so I'd rat...

How do I get Hibernate to call my custom typedef?

I'm trying to define a CompositeUserType to handle a specific type in my JPA/Hibernate app. I have a CompositeUserType called ApplicationMessageType that is designed to handle my mapping. According to what I've read, I should be able to create a package-info.java class in my domain hierarchy that contains the TypeDefs. Mine looks like ...

Default method return value in Java

While working with annotations I stumbled accross the following piece of code (it's the Hibernate @NotNull annotation): @Target(value = {ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER}) @Retention(value = RetentionPolicy.RUNTIME) @Documented @Constraint(validatedBy = {}...

Does Eclipse not show @documented parameter annotations?

I annotated a method's parameters with a @NotNull annotation, which itself had the @Documented annotation. I'm not seeing the parameter annotations displayed anywhere. In contrast, the annotations on the method itself are displayed. Is there some way to make the annotations show up, ie. in the javadoc? //test method @NotNull Object fo...

Hibernate not populate data from mapping table

I have User class and Country class with respective tables. Country table data is fixed. I make a mapping table User_Country(userid, countryid) and following mapping in User class @OneToMany(fetch=FetchType.EAGER) @JoinTable(name = "User_Country", joinColumns ={ @JoinColumn(name = "userid") }, inverseJoinColumns...

SEAM: Effective use of @BypassInterceptors?

I was wondering what advice the community could give me on the use of the @BypassInterceptors annotation when programming with Seam? I've been reading up on increasing Seam application performance, and without fail every article mentions that adding this annotation can increase performance. My question is, where should it be applied? ...

Unit testing controllers with annotations

Hi there, I'm trying to write some unit tests for my controllers in a Spring MVC web app. I have already got a fairly comprehensive set of unit tests for the domain model, but for completeness I want to test the controllers too. The issue I'm facing is trying to test them without loading a Spring context. I thought I could get around...

nested Annotation List in Scala

Help, how do i do stuff like the following in Scala? import org.hibernate.validator.constraints.ScriptAssert @ScriptAssert.List({ @ScriptAssert(script = "...", lang = "javascript"), @ScriptAssert(script = "...", lang = "javascript")}) ...

Inherited abstract class with JPA (+Hibernate)

How would you configure annotations in the following example code? I'd like to stick with JPA annotations only and avoid Hibernate specific dependencies. Is the code below correct? @Entity public class RefExample extends RefData { } (There will be multiple versions of these classes, RefSomeOtherExample, etc, and one db table per clas...

Applying annotations to fields inherited from @MappedSuperclass

Has: @MappedSuperclass class Superclass { @Id @Column(name = "id") protected long id; @Column(name="field") private long field; } and @Entity class Subclass extends Superclass { } How to annotate inherited id with @GeneratedValue and field with @Index within Subclass? ...

how to use zk annotations

Hi, I am using zk 5.0.3. I want to use the following annotation binding as the title of a "center" region of a borderlayout: <a:bind content="entrydisplay.activeEntryCaption" /> <html /> I want to do the following: <borderlayout> <north title="use the above binding here"> this is north </north> </borderlayout> How do I achie...

Smooth annotation movement on OS 4

Hi, To move custom annotations in my MKMapView class, I remove all annotations first and add them (which are placed in new locations) again every second. It was perfectly working on iOS 3 but when I updated my OS and XCode to version 4.0, the annotations blink instead of smooth movement they used to have in previous version. Any sugges...

Java Annotations - looking for an example of RetentionPolicy.CLASS

Hi, according to Java Annotation API: RetentionPolicy.CLASS Annotations are to be recorded in the class file by the compiler but need not be retained by the VM at run time. RetentionPolicy.RUNTIME Annotations are to be recorded in the class file by the compiler and retained by the VM at run time, so th...

I have an iphone application which uses dragging of annotations on a MapView, is this possible is the iPad?

I am trying to use: - (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)annotationView didChangeDragState:(MKAnnotationViewDragState)newState fromOldState:(MKAnnotationViewDragState)oldState And was getting errors when building this for the iPad, but I have since realised that it is iOS 4 specific, so it won't work ...

@BeforeClass still running the method everytime any test is run

I am using the @BeforeClass annotation to ensure that a set of activities are done just once in a set of 5-6 tests. There is a hierarch of 3 java files. File1 extends TestCase File2 extends File 1 (this is where i have to put the beforeclass annotation at the setUp method) File3 extends File2 (File 3 has the tests.. 5 in number, b...

Annotation processing: Types.isSubtype does not work for generics ??

Hi, I have the following problem in my AnnotationProcessor (Java 1.6) when checking if one Type is a subtype of another: public interface IGeneric { public boolean isGeneric(T value); } and the implementing type public class Test implements IGeneric { @Override public boolean isGeneric(final String value) { ... ...

Hibernate annotation unnecessary delete and insert

I have a class A which has set of class B. class A and class B has their own table. When i insert class A it also insert class B. When i update class B, Hibernate deletes everything from class B which belongs to that instance of A and then insert all values in current set B. I want that if only 2 new values are added in set b, then it on...

Should I use @Override tag when implementing an interface method?

Should I put the @Override tag if I am implementing a method of an interface? I know @Override tag should be there when you override a method of super class (not an interface). But how about implementing a method of an interface? ...