annotations

How to map one class to different tables using hibernate/jpa annotations

I'm currently stuck with what seems to be a very simple problem, but I just can't seem to find a way around: I have 2 identical tables: tbl_creditcard_approved_txns tbl_creditcard_declined_txns The fields in both are identical, and I have one class - Transaction that is used to represent all the appropriate fields in the tab...

javax.persistence annotations and inheritance

I have 4 persistent classes which all have the same fields (exactly) the only 3 difference between them is 1) the class name, 2) the table name and 3) the data. i am aware that this might seem strange to some but trust me there is a good reason which i won't go into here. now, i'm using hibernate annotations to configure my class which ...

Spring @Transactional wrapping 2 methods

Hello I'm a Spring newby. I use the @Transactional annotation for my dao methods: @Transactional public Person getById(long id) { return new Person(jdbcTemplate.queryForMap(...)); } @Transactional public void save(Person person) { jdbcTemplate.update(...); } and I've set up the transaction manager like this: <tx:annotation-...

How to see javadoc for annotations in Android SDK ?

In "Documentation for Android SKD, API 8", the javadoc for class android.test.InstrumentationTestRunner mentions command-line options for "small", "medium", and "large" tests without explaining how one would define tests as being of those sizes. A clue arrives later in the description in the form of a link to the annotation android.test....

Howto write unittests for struts 2 annotated based validation?

Hi! I am using annotation based validation in Struts 2.1.8.1. Now i want to write a unit-test using jUnit 4 for them but have not got a clue how to do it. I found several links which worked in Struts 2.1.6 but not in Struts 2.1.8.1 anymore: http://bloodredsun.blog.com/2009/10/21/unit-testing-struts2-actions-with-annotation-based-valid...

How to create optional parameter for Own Annotation ?

Following is the Annotation Code public @interface ColumnName { String value(); String datatype(); } I would like to make datatype an optional parameter. ie. @ColumnName(value="password") should be a valid code. ...

spring mvc annotation - object missing values on post

I have a domain object with 5 property. I preload the object in my GET method and display just one of the property in the form. When the form gets submitted, the object contains only one property with value. How do I get the remaining properties and their values without putting a hidden variable for each property in my form. ...

spring mvc annotation - dummy form variable

I have a form with two select boxes that are used to move values from one box to another. I need to submit values only from second select box to my ModelAttribute. How do i prevent spring mvc from complaining about "unable to bind" on my first selectbox. ...

Creating Indexes on DB with Hibernate @Index Annotation

I have annotation-driven hibernate capabilies on my project. Now I want to create an index over a column. My current column definition is @NotNull @Column(name = "hash") private String hash; and I add @Index annotation here. @NotNull @Column(name = "hash") @Index(name="hashIndex") private String hash; and then DROP TABLE and resta...

How do I get constants defined in my service using JAX-WS?

I have a webservice that I'm using JAX-WS annotations to generate the WSDL & associated client code (writing both ends, just using JAX-WS for the transport). I've got a method that can have different return values depending on the state of the request, @WebMethod public int uploadResults( @WebParam(name="authentication") Ser...

Validate against javax bind annotations rather than schema

Been using latest JAXB Sun implementation but can rely on the XJC to generate correct annotations. Have several examples whereby the XJC doesn't attached XMLElement or XMLAttribute annotations for no logical reason. Plus have problems with the logic behind the plugins framework. Anyways I want to ditch the idea of writing schemas just...

@Override for interface methods causes JSP compilation to fail.

For some reason, putting @Override on methods overriding interface methods causes JSP compilation to fail in weblogic. Everything is definitely running off of JDK 1.6.0_14, but this Java 5'ism still persists. Oddly, JSP compilation occasionally fails with a stacktrace pointing at code not necessarily obviously used by the JSP itself. W...

Java Annotations: ElementType?

java.lang.annotation.ElementType: A program element type. The constants of this enumerated type provide a simple classification of the declared elements in a Java program. These constants are used with the Target meta-annotation type to specify where it is legal to use an annotation type. There are the following constants: ANNOTATION...

java.sql.SQLException: Cannot add or update a child row: a foreign key constraint fails

Hi Could someone help me understand that why am I getting the following error when I am trying to persist ServiceProvider entity? java.sql.SQLException: Cannot add or update a child row: a foreign key constraint fails (`springmvc/businesslocation`, CONSTRAINT `FK5CB747B5A26ED80E` FOREIGN KEY (`state_id`) REFERENCES `state` (`id`)) at ...

Hibernate and Inheritance (TABLE_PER_CLASS)

Hi, I use Hibernate to persist inherited objects but I got this message when I try to persist objects in database: org.springframework.dao.InvalidDataAccessResourceUsageException: Could not execute JDBC batch update; SQL [update Widget set CONTAINER_ID=? where WIDGET_ID=?]; nested exception is org.hibernate.exception.SQLGrammarExceptio...

Using a default class literal value on an annotation.

I want to annotate some of the fields of a given bean class with the following annotation: @Target({FIELD}) @Retention(RUNTIME) public @interface Process { Class<? extends ProcessingStrategy> using() default DefaultImplStrategy.class; } Without going into the domain too much, each annotated property needs to have a ProcessingStr...

Pointcut matching methods with annotated parameters

I need to create an aspect with a pointcut matching a method if: it is annoted with MyAnnotationForMethod One of its parameters (can have many) is annotated with @MyAnnotationForParam (but can have other annotations as well). The aspect class look like this @Pointcut("execution(@MyAnnotationForMethod * *(..,@aspects.MyAnnotationForP...

Why doesn't a missing annotation cause a ClassNotFoundException at runtime?

Consider the following code: A.java: import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @Retention(RetentionPolicy.RUNTIME) @interface A{} C.java: import java.util.*; @A public class C { public static void main(String[] args){ System.out.println(Arrays.toString(C.class.getAn...

Scala Annotation List?

I wanted to ask if there is a list of annotations for Scala 2.8.0? I stumbled upon @inline and @specialized but it would be nice if there is a complete list which also explains what they do exactly. If such a list doesn't exist: Are there some annotations one should be familiar with? ...

Hibernate: cant get the associated List retrieved

Hi An entity X has a list of entity Y and the entity Y has an instance of entity Z. The relation between X to Y is OneToMany and the relation between Y to Z is ManyToOne. I want to retrieve X and have all the associated entities retrieved with them as well. What HQL query do I write so that I get the whole chain retrieved all at once...