Questions tagged [java-annotations]
211 questions
0
votes
1 answer
Sequence Generator not available to child class (entity) in certain cases
I've successfully defined a sequence generator via annotations in an inheritance relationship roughly like so:
@MappedSuperclass
public class DomainObject {
@Id
@Column( columnDefinition = "serial" )
@GeneratedValue( generator =…

Mark Nenadov
- 6,421
- 5
- 24
- 32
0
votes
1 answer
Add "symbol" field to Java class
I have a library, I have to tag a class with certain field dynamically (code generation) and I don't want the meta-data field names I generate to clash with user-defined field names.
Using JavaScript, we can use ES6 Symbols to do this. We can create…

Alexander Mills
- 90,741
- 139
- 482
- 817
0
votes
0 answers
Can I Access the JobExecutionContext while using ScopedProxyMode in Java Annotations
I am trying to create a bean and am having some issues. Here is my current configuration for it.
@Bean(name = TDA_JDBC_CURSOR_ITEM_READER)
@Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS)
public…

Patrick Aquilone
- 584
- 2
- 11
- 28
0
votes
1 answer
Spring Boot get name of main class at runtime
I am trying to write a scanner for custom annotations based on the answer in Scanning Java annotations at runtime.
However, to speed up the process, I only want to scan the classes under the main package (package which has the main class and its…

Anoop
- 813
- 2
- 10
- 24
0
votes
1 answer
making @XmlElements dynamic
The docs for the annotation type @XmlElements has this example:
public class Foo {
@XmlElements(
@XmlElement(name="A", type=Integer.class),
@XmlElement(name="B", type=Float.class)
}
public List items;
}
This is great…

Sam Carleton
- 1,339
- 7
- 23
- 45
0
votes
1 answer
Emit real time errors and warnings from annotation processor
Currently I'm working on an annotation in Java and everything works great. My AbstractProcessor creates the new files and can emit errors and warnings when needed. What is not working are real time errors and warnings. So what do I mean with…

Cilenco
- 6,951
- 17
- 72
- 152
0
votes
1 answer
Spring @schedule task does not return
I have a Spring @scheduled task in my application that will start every 2 minutes. In some situation, the task never comes back so the task will not execute after this.
@Scheduled(fixedDelay = ....)
private void task() {
}
Anyway to set a timeout…

user2777473
- 3,736
- 5
- 26
- 39
0
votes
1 answer
How do I get the real annotation instead of a proxy from ConstraintDescriptor::getAnnotation? (javax.validation Apache Bval)
I'm trying to get a Class object reference for the annotation which caused a ConstraintViolation in the javax.validation package (Apache Bval implementation).
After getting some ConstraintViolations, I pass them into the following function:
private…

A Frayed Knot
- 476
- 5
- 20
0
votes
1 answer
how to read class name passed to class annotation from the annotation
I have created my own annotation and this annotation receives class.class. The class itself is extending another class.
I am trying to achieve almost the same as using @RunWith(), but instead of running the class I would like to use it to get the…

Yoav Tanzman
- 51
- 5
0
votes
2 answers
why passing an identifier to @size annotated method not working?
this is the problem I'm trying to solve.
TextView[] containers=new TextView[2];
and I am calling following mehtod.
compeletLogin(containers);
and following is the method declaration.
private void compeletLogin(@Size(2) TextView[] containers) {
…

Urvish rana
- 601
- 10
- 24
0
votes
2 answers
Cumulocity Java SDK: updating ManagedObjectRepresentation
The update function of InventoryApi returns a ManagedObjectRepresentation object of the result.
In my code, I successfully use update() and later, try to update the returned ManagedObjectRepresentation (e.g. set some fragments), calling…

jakob
- 35
- 1
- 1
- 5
0
votes
0 answers
Java: Replace null values of collection type fields empty collection
Is there a way to parse a nested java object which has multiple collection fields few of them are nulls.
I need something like this
@EmptyCollectionIfNull
private List names;

shoaib1992
- 410
- 1
- 8
- 26
0
votes
1 answer
AOP not invoked by annotation
I am trying to invoke a AOP method for every method that is annotated with @Timed.
My AOP MyTracer.java
@Aspect
public class MyTracer {
private static final Tracer tracer = Tracing.getTracer();
private static final Logger log =…

Neil
- 5,919
- 15
- 58
- 85
0
votes
1 answer
Java Spring batch access command line arguments in XML and Java Annotation config
How can I get the command line arguments in a xml configuration file with spring?
With property file I can write this:

michele
- 26,348
- 30
- 111
- 168
0
votes
1 answer
Java - Force a class implementing an interface to declare an annotation
I'm trying to force class SomeImpl to declare an annotation @SomeAnnotation if it is implementing interface SomeInterface. Solution can modify SomeInterface declaration.
public interface SomeInterface {}
public class SomeImpl implements…

italktothewind
- 1,950
- 2
- 28
- 55