annotations

Hibernate Enum mapping using annotaions

I have an existing database that I am now connecting to using hibernate. I cannot change the data in it at the moment and have everything working apart from a single column. I have a status column that has the values: new mailed in out And the column is mapped as follows: @Column(name = "STATUS", nullable = false, length = 50) @En...

How should we use clientId and subscriptionName in annotations for multiple durable subscriber MDBs?

We are implementing an events framework within our application using a JMS topic with multiple durable subscribers as MDBs (EJB 3.0). Each subscriber will use message selectors to determine which messages it is interested in. How should we specify clientId and subscriptionName values in @ActivationConfigProperty annotations? My current ...

Documenting use of EJB3 annotations within a code base

Hey, We have a large code base and I want to generate specific reports on the usage of EJB3 annotations within the code base. The simplest use case is to generate a HTML/PDF report with details of all classes/methods that use the EJB3 security annotations. The goal of this document is to allow non developers to simply review which inter...

Hibernate @GeneratedValue annotation setting existing value to new Object (violating primary key constraint)

Hi, I have an attribute set like: @GeneratedValue @Id private long id; Howerver, when I call the persist function, the id is set with a value that already exists in my Postgres database. I checked the my_seq field there and it is set correctly so I don't know where hibernate is getting that existing number from. Note that this was w...

Java APT and __LINE__

In another post (http://stackoverflow.com/questions/3396074/scala-maven-and-preprocessors) I asked about preprocessing Java and Scala using a tool like m4. I need to add __FILE__ and __LINE__ capabilities (please, no "use cases" questions). Someone suggested checking out Java compiler plugins (javax.annotation.processing.Processor). How...

Typesafe enum in Java

Hello, Not sure whether the title is misleading, but requirement is below. I need to use a string value as input to a custom annotation. When use an enum value, the IDE gives java attribute value must be constant. @test("test") // works @test(Const.myEnum.test.toString()) //java attribute value must be constant I read abou...

JAXB: how to tell whether a class is Marshalable without annotations

We have a class, with no control over the source, so no way to annotate it for JAXB. We also have a framework to take care of marshaling. Is there any way for this framework to ask that class whether it is marshallable when no annotations are present? ...

Would Servlet 3 annotations enable secret backdoor access?

I hope people don't mind me asking a question which is slightly future gazing. Please forgive me if my understanding is incorrect (and please put me right!). Servlet 3 introduces several new annotations including: @WebServlet @WebFilter @WebListener and also a something called web-fragment.xml. These all seem to be aimed at maki...

Autowiring Validation without Naming Controllers After Models in Spring

Very new to spring and working my way through validation. I have examples working where I actually implement the spring Validator class, but am working on getting examples working without implementing the Validator class and instead using annotations directly on model class attributes such as @NotBlank and @Email. My question is this. ...

How to use Annotations with iBatis (myBatis) for an IN query?

We'd like to use only annotations with MyBatis; we're really trying to avoid xml. We're trying to use an "IN" clause: @Select("SELECT * FROM blog WHERE id IN (#{ids})") List<Blog> selectBlogs(int[] ids); MyBatis doesn't seem able to pick out the array of ints and put those into the resulting query. It seems to "fail softly" and we ...

Spring 3 Portlet - data not updating on a page refresh

I'm trying to write a simple portlet using Spring 3 to run in Liferay. It's two pages - you can view an ordered list of items (they are just strings), and if you go to the edit page, you can change the order of the items in the list. On the edit page, you can either move an item up or down, one level at a time. So for example, when you c...

Combine annotations in Java

How can I combine annotations in Java? EDIT I was asking if I two annotations a and b, can I combine to a single annotations c? If possible, how do I do that? ...

Best Practises for Polymorphic JPA via Annotations

I'm trying to set up polymorphic behaviour using Hibernate with JPA annotations. It seems sensible (maybe even necessary) to create an (abstract) class encapsulating the state and behaviours required for the inheritance hierarchy to participate in persistence; for example I need to annotate an Id property, which I cannot do in an inte...

What's needed to handle annotation viewing in a PDF?

Hey everyone, I am working on parsing the PDF content stream to be able to read and handle annotation operators and also to add these. Can anyone shed some light on how to go about doing this, without using a prebuilt library? I understand it is a daunting exercise, but any pointers would be appreciated. Note: I've read a fair amount of...

using only annotated mappings

Hello, I'm having some problems removing mappings from my dispatcher-servlet.xml file. I've annotated some controllers with @RequestMapping, am using spring 3.0.3, and have all the correct includes. Shouldn't this work? ...

Hibernate annotation configuration with Spring can't find domain object

I am having a problem with Hibernate seeing my domain objects doing a purely annotation configuration for Hibernate. I'm getting org.hibernate.hql.ast.QuerySyntaxException: User is not mapped [from User u where u.userName=:userName] I thought all that had to be done was add the packagesToScan property for the sessionFactory and add @E...

Hibernate: Retrieving Lists

Hi folks, I am a beginner with hibernate. My intetions are really simple: I have mapped objects into one table with annotations. Now I want to retrieve them as a List of objects to display them. Later I want to implement simple filters. Do I need to write SQL Queries? or is there a kind of Annotation based method? Option 1: see Rup...

Spring MVC annotation preload form

I am a newbie to spring mvc annotations. Which is the best way to load data into a page that has say a string, list (list of country for a drop down) and some form elements like name and address I see two possible ways @ModelAttribute on a method - can be used for string, list, initialize the form elements Put the string, list into Mo...

How to specify that a combination of columns should be a unique constraint using annotations?

I want to make sure that all rows in my table have a unique combination of two fields, and I want to specify this using annotations in my entity class. I have tried using a combination of @Table and @UniqueConstraint but apparently I'm doing it wrong, in that I can only seem to specify that the separate columns should be unique (I can a...

I want to know if it is possible to create a Java Annotation that enforces a specific Return Type?

I want to know if it is possible to create an Annotation that enforces a specific Return Type? What I would like is a way to create an Annotation and use it like: @MarkerAnnotationForcingStringReturnType public String someWebflowMethod(...){ ... return "someString"; } Then I can have any method name I want, but it will have t...