|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2007 the original author or authors. |
|
|
|
* Copyright 2002-2009 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
@ -16,6 +16,10 @@ |
|
|
|
|
|
|
|
|
|
|
|
package org.springframework.dao.annotation; |
|
|
|
package org.springframework.dao.annotation; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.lang.annotation.Target; |
|
|
|
|
|
|
|
import java.lang.annotation.ElementType; |
|
|
|
|
|
|
|
import java.lang.annotation.Retention; |
|
|
|
|
|
|
|
import java.lang.annotation.RetentionPolicy; |
|
|
|
import javax.persistence.PersistenceException; |
|
|
|
import javax.persistence.PersistenceException; |
|
|
|
|
|
|
|
|
|
|
|
import junit.framework.TestCase; |
|
|
|
import junit.framework.TestCase; |
|
|
@ -109,6 +113,10 @@ public class PersistenceExceptionTranslationAdvisorTests extends TestCase { |
|
|
|
doTestTranslationNeededForTheseExceptions(new MyStereotypedRepositoryInterfaceImpl()); |
|
|
|
doTestTranslationNeededForTheseExceptions(new MyStereotypedRepositoryInterfaceImpl()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void testTranslationNeededForTheseExceptionsWithCustomStereotype() { |
|
|
|
|
|
|
|
doTestTranslationNeededForTheseExceptions(new CustomStereotypedRepositoryInterfaceImpl()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void testTranslationNeededForTheseExceptionsOnInterface() { |
|
|
|
public void testTranslationNeededForTheseExceptionsOnInterface() { |
|
|
|
doTestTranslationNeededForTheseExceptions(new MyInterfaceStereotypedRepositoryInterfaceImpl()); |
|
|
|
doTestTranslationNeededForTheseExceptions(new MyInterfaceStereotypedRepositoryInterfaceImpl()); |
|
|
|
} |
|
|
|
} |
|
|
@ -142,6 +150,7 @@ public class PersistenceExceptionTranslationAdvisorTests extends TestCase { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public interface RepositoryInterface { |
|
|
|
public interface RepositoryInterface { |
|
|
|
|
|
|
|
|
|
|
|
void noThrowsClause(); |
|
|
|
void noThrowsClause(); |
|
|
@ -149,6 +158,7 @@ public class PersistenceExceptionTranslationAdvisorTests extends TestCase { |
|
|
|
void throwsPersistenceException() throws PersistenceException; |
|
|
|
void throwsPersistenceException() throws PersistenceException; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static class RepositoryInterfaceImpl implements RepositoryInterface { |
|
|
|
public static class RepositoryInterfaceImpl implements RepositoryInterface { |
|
|
|
|
|
|
|
|
|
|
|
private RuntimeException runtimeException; |
|
|
|
private RuntimeException runtimeException; |
|
|
@ -170,29 +180,49 @@ public class PersistenceExceptionTranslationAdvisorTests extends TestCase { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Repository |
|
|
|
@Repository |
|
|
|
public static class StereotypedRepositoryInterfaceImpl extends RepositoryInterfaceImpl { |
|
|
|
public static class StereotypedRepositoryInterfaceImpl extends RepositoryInterfaceImpl { |
|
|
|
// Extends above class just to add repository annotation
|
|
|
|
// Extends above class just to add repository annotation
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static class MyStereotypedRepositoryInterfaceImpl extends StereotypedRepositoryInterfaceImpl { |
|
|
|
public static class MyStereotypedRepositoryInterfaceImpl extends StereotypedRepositoryInterfaceImpl { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@MyRepository |
|
|
|
|
|
|
|
public static class CustomStereotypedRepositoryInterfaceImpl extends RepositoryInterfaceImpl { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Target({ElementType.TYPE}) |
|
|
|
|
|
|
|
@Retention(RetentionPolicy.RUNTIME) |
|
|
|
|
|
|
|
@Repository |
|
|
|
|
|
|
|
public @interface MyRepository { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Repository |
|
|
|
@Repository |
|
|
|
public interface StereotypedInterface { |
|
|
|
public interface StereotypedInterface { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static class MyInterfaceStereotypedRepositoryInterfaceImpl extends RepositoryInterfaceImpl |
|
|
|
public static class MyInterfaceStereotypedRepositoryInterfaceImpl extends RepositoryInterfaceImpl |
|
|
|
implements StereotypedInterface { |
|
|
|
implements StereotypedInterface { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public interface StereotypedInheritingInterface extends StereotypedInterface { |
|
|
|
public interface StereotypedInheritingInterface extends StereotypedInterface { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static class MyInterfaceInheritedStereotypedRepositoryInterfaceImpl extends RepositoryInterfaceImpl |
|
|
|
public static class MyInterfaceInheritedStereotypedRepositoryInterfaceImpl extends RepositoryInterfaceImpl |
|
|
|
implements StereotypedInheritingInterface { |
|
|
|
implements StereotypedInheritingInterface { |
|
|
|
|
|
|
|
|
|
|
|