annotations

NSFetchedResultsController for map annotations

The documentation for the NSFetchedResultsController states that it is intended for use to 'efficiently manage the results returned from a Core Data fetch request to provide data for a UITableView object'. Could I use an NSFetchedResultsController to manage a collection of map annotations as well? I am not sure how I would do this. Any ...

Java beans, annotations: What do they do? How do they help me?

Here is what what I understand so far: Java beans are just to help other things (visual things?) interact with your code. I think that this is mostly for UI stuff because it is easier to design this visually. Is it bad practice to use Java beans for non-UI things? Java beans have getter and setter methods (bad OOP practice) and are...

Hibernate MappingException Unknown entity: $Proxy2

I'm using Hibernate annotations and have a VERY basic data object: import java.io.Serializable; import javax.persistence.Entity; import javax.persistence.Id; @Entity public class State implements Serializable { /** * */ private static final long serialVersionUID = 1L; @Id private String stateCode; private String stateFullName; ...

Is there a way to prevent null values from being persisted while allowing others through?

I have an existing JPA (EclipseLink) project where the desired behaviour is that if given a null value in a field for an entity, that null value should not be persisted. The use case is that we may get several partial updates to these entities from external sources. Those sources may give us a null value, that does not mean "nullify thi...

apt warning: no annotation processor found

I am just teaching myself about web services right now and trying to run a helloWorld. I think that to setup all of the web service stuff I need to run apt. I am running it like this: apt HelloImpl.java -classpath /<path>/jsr181-api.jar But I am getting a warning (see below). Do I need to specify an annotation processor too? I t...

scala: annotating accessor methods

class Foo { @SomeAnnotation var bar: String = _ } @SomeAnnotation is a Java annotation (so it is kept at runtime) with runtime retention and Method target. The code compiles, but at runtime the bar() and bar_=() methods that the compiler generated are not annotated. Assuming this is not a bug, is there a clean way of annotating t...

What's the point of package annotations?

I understand the purpose of class annotations: http://stackoverflow.com/questions/1372876/how-and-where-are-annotations-used-in-java. But what is the purpose of package annotations, as described here and here? Why would you want to associate meta-data with a package? What kinds of things could you do? ...

How to find type of Annotated function parameter

Suppose I have a function public int doSomething(@QueryParam("id") String name, int x){ .... } How can I find the type of the annotated parameter 'name'. I have a handle to the java.lang.reflect.Method instance of the function doSomething and using the function getParameterAnnotations(), I can obtain the annotation @QueryParam but am...

How to write annotations using multiple enum types?

I'm attempting to write some annotations to help associatate test case methods with various metadata. My annotations so far include BugFix, UseCase, and Requirement. My end goal is to write an annotations processor to display which test cases are associated with individual bug fixes, use cases, and requirements. When I was just implem...

Persisting large files with Hibernate Annotations

I am using Hibernate Annotations for the first time in my web application. In my bean, what type what annotations should I use to persist files uploaded by users? ...

Issue persisting long strings with Hibernate

In my web application, I have a text area whose user-filled contents are ultimately persisted to the db with Hibernate. I have been running into an issue that when the user input is beyond a certain length, the persistence fails. Is there a way to indicate through Hibernate Annotations or in the configuration that this particular field...

Automatic documentation from PHP code.

OK I know there's PhpDocumentor for generating documentation from php code. It seems it hasnt been updated in a long time (but maybe they figure its mostly feature complete). While this might be good for documenting things for other programmers, it doesn't seem well suited for documenting the external "API" of a web service. IE, if I'...

SQLite injection with list of strings

Hello, Could anyone tell me a way to prevent sql injection when building queries for SQLite where the WHERE clause has an "myval IN (string_1, ... , string_n)" condition ? I though about dynamically building the command text with annotations and adding the parameters for those annotations from the string list. Is there an easier way ? ...

Java Web service using Apt. Do I need an annotation processor? What is wrong?

I have been trying to make a simple web service and have been following this tutorial . Unfortunately I am stuck. Here is what I have done so far: 1) I created this class: package server; import javax.jws.WebService; @WebService public class HelloImpl { /** * @param name * @return Say hello to the person. */ public S...

What's the conception behind: Type - Element - Mirror

I'm working with Java 6's annotation processing, i.e. what can be found within javax.annotation.processing (not Java 5's APT). I wonder what the conceptional difference between the various Element, Type, and Mirror classes is. As I don't really understand this, it's hard to efficiently program an annotation processor. There are various ...

Hibernate not creating correct fields for Clobs in MySQL

I have a String in my Entity @Column(length=40000) @Lob private String introText; The column in my MySQL database that Hibernate creates for introText is a varchar(255), which doesn't jive with the column length or @Lob annotation. Any ideas? I'm relatively new to Hibernate, so I wonder if I'm missing any other settings or configura...

Hibernate - How to cascade deletes using annotations where only unidirectional child relationship is specified

Supposing I have two entities a parent object and a child. I want the child to have a relationship specified to the parent entity and a reference, but I don't want the parent to have to know about it. The reason for this is there are numerous such relationships and explicitly specifying the relationship for all these children will mean...

Testing, Mocking framework support for recording annotations (preferrable easymock solution)

We have developed some code which analyzes annotated methods and adds some runtime behaviour. I would like to test this. Currently I am hand-coding stubs with certain annotations for setting up my test-case. Usually I am using a mocking-framework (currently easymock) to avoid hand-coding test-doubles (stubs or mocks). But I haven't foun...

Can I get Java 5 to ignore @Override errors?

I have some Java code that was written using Eclipse and the Java 6 SDK, so methods that implement an interface are annotated with @Override - an annotation that is legal in Java 6, but not in Java 5. I'd like to compile the same code using the Java 5 SDK (javac on Mac OS X 10.5). Everything compiles and runs fine except for the @Overri...

Is there a way to get Hibernate's hbm2ddl Ant task to exclude specific tables?

I use Hibernate to generate my database automatically for testing, and I have some tables in my schema that contain static data that takes a very long time to import. In the past, I've used the following code in my build file to generate the database (from mapping files): <target name="schema-gen" depends="hibernate-gen"> <taskdef n...