annotations

Hiber cache : Cache all fixed data permanently

I have few tables like Country,state city which has static data. User do not enter any data in this data. I create pojo for Country, State, City. There are few pojo which has mapping with static data. My requirement is that whenever any request comes to Hibernate for Country (21), it do not hit database but return data from cache . Is th...

Mapping entities with composite keys

I am working on converting a legacy system to use hibernate (version 3.3.x) instead of using hand crafted SQL. I have run in to some problems mapping my datamodel that pertians to composite keys. I've created a solution I think works, but I am not overly fond of it. Hence, I would like to see how the diagram below could/should be mapped ...

JPA - using annotations in a model

My application runs on JPA/Hibernate, Spring and Wicket. I'm trying to convert our ORM from XML files to JPA annotations. The annotated model looks like this: @Entity @Table(name = "APP_USER") public class User extends BaseObject { private Long id; private String firstName; private String lastName; private String email; ...

Custom annotations to set HTTP response headers in a JAX-RS service

I have a JAX-RS web service for which I would like to disable the same-origin policy via the new CORS HTTP headers. (I am fully aware of the security implications.) I'd like to have a custom annotation that lets me set HTTP response headers. For example, @ResponseHeaders({"Access-Control-Allow-Origin: *", "Access-Cont...

Hibernate: how to specify clustered index annotation

I want to create an annotated class similar to that: @Entity @MappedSuperclass @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) public class SeriesMonitoringPointsTable { @Id @Column(name = ID, nullable = false) private Long id; public void setId( Long id ) { this.id = id; } } In this class I woul...

Nested annotations in RelaxNG?

Trying to get the following XSD output from RelaxNG, using Trang for conversion: <xs:annotation> <xs:documentation>Basic documentation text here.</xs:documentation> <xs:appinfo> <jxb:class name="VmlLocation"> <jxb:javadoc> Javadoc text here. </jxb:javadoc> </jxb:class> </xs:appinfo> </xs:annotation> .. but none of the methods for decl...

How to mix inheritance strategies with JPA annotations and Hibernate?

According to the Hibernate Reference Documentation it should be possible to mix different inheritance mapping strategies when using Hibernate's XML-Metadata: http://docs.jboss.org/hibernate/stable/core/reference/en/html/inheritance.html#inheritance-mixing-tableperclass-tablepersubclass However, the corresponding section of the Hibernate...

Non-void test methods in JUnit 4

I would like a JUnit 4 test class to implement the same interface as the class its testing. This way, as the interface changes (and it will, we're in early development), the compiler guarantees that corresponding methods are added to the test class. For example: public interface Service { public String getFoo(); public String getB...

How do I implement this image annotation javascript using AJAX with Rails?

There is a blog post that details how to do this with PHP, but I'm not clear on how to translate this to Ruby on Rails. For the getUrl, saveUrl, and deleteUrl what do I put so that I can hook it up to my AnnotationsController and create, read, and delete Annotation models? There is also server side code in PHP. jquery-image-annotate i...

How to resize callout bubble after resetting title/subtitle

Hi all, I created an MKAnnotation name PushPin which has a title and subtitle. I want to be able to dynamically change the title at a later time. I'm close so I'd rather not have to make a whole new AnnotationView, but if I have to I guess that's ok too. My problem is that, once I change the text for the title, the window does not re...

How to view annotation of java classfile via command line?

Hi, Is there a command line tool, preferrably in the JDK, that either prints all annotations in a classfile or takes a specific annotation as argument to print? If so, is there an equivalent command that can be run on a jar file for a specific class contained within? I've googled this for a while and had no luck. :( Thanks, Jack ...

Java: automatic memoization

I have a few functions in my code where it makes much sense (seems even mandatory) to use memoization. I don't want to implement that manually for every function separately. Is there some way (for example like in Python) I can just use an annotation or do something else so I get this automatically on those functions where I want it? ...

Any way to inject/choose datasource at runtime?

I have a MySQL database with many databases, each named for a specific customer. A webapp is deployed per customer. The name of the webapp determines the underlying database name. When the webapp starts up, I have a modified Spring PropertyPlaceholderConfigurer to grab the ServletContext if it can and determine the name. I then derefere...

Hibernate - AnnotationConfiguration deprecated

Hello! I am using Hibernate in version 3.6.0 and the AnnotationConfiguration is marked as deprecated. Here is the the line in my HibernateUtil.java class: sessionFactory = new AnnotationConfiguration().configure("/hib.cfg.xml").buildSessionFactory(); What's the replacement for AnnotationConfiguration? Best Regards Tim. ...

How to disable testng test based on a condition

Hey Guys, Is there currently a way to disable Testng test based on a condition I know you can currently disable test as so in Testng: @Test(enabled=false, group={"blah"}) public void testCurrency(){ ... } I will like to disable the same test based on a condition but dont know how. something Like this: @Test(enabled={isUk() ? false ...

Using Spring annotations, how can we use DI with a superclass via annotations?

I have the following class defined as a bean: @Repository("userDao") public class UserDao extends JdoDaoSupport implements IUserDao {...} The class JdoDaoSupport requires a persistenceManagerFactory injected into it. I've declared the persistenceManagerFactory bean in XML, how do I inject it to my superclass using annotations? JdoDa...

Java: collection that allows objects with a custom annotation

I'd like to annotate some classes with a @MyEntity annotation public @interface MyEntity {} @MyEntity public class MyClass { ... } And define a collection where only classes with that annotation are allowed (with no need to define them as public class MyClass implements XXX): List<MyEntity> list = new ArrayList<MyEntity>(); list.add...

Wrong query generated with @OrderBy annotation

Hi, I am using Hibernate3 and i have an entity with the following collection: @ManyToMany @JoinTable(name = "buys_publishers", joinColumns=@JoinColumn(name="buy_id", referencedColumnName = "buy_id"), inverseJoinColumns=@JoinColumn(name = "publisher_id", referencedColumnName = "publisher_id")) @OrderBy("name") private List<Publi...

Flex and Video Annotation

I have been investigating how to annotate video using Flex or AIR. Similar to how it is being done on YouTube. I am not getting much joy. Wondered if anybody might have any insight? Thanks --Matt ...

How Would One Find a Dependency-Order list of Tables to Delete for Test Data?

I have a test suite that needs to delete any existing data in my local MySQL test instance for a large number (but not all) of the tables in the system. delete from customer; Of course, customer has quite a few foreign keys to it, so I also have to delete a few more tables... delete from customer_email; delete from customer_phone;...