Permalink
Showing with 6,446 additions and 7,363 deletions.
  1. +3 −1 .gitignore
  2. +291 −0 formatting.xml
  3. +104 −115 src/main/java/org/springframework/data/jpa/domain/AbstractAuditable.java
  4. +90 −100 src/main/java/org/springframework/data/jpa/domain/AbstractPersistable.java
  5. +9 −11 src/main/java/org/springframework/data/jpa/domain/Specification.java
  6. +88 −103 src/main/java/org/springframework/data/jpa/domain/Specifications.java
  7. +58 −72 src/main/java/org/springframework/data/jpa/domain/support/AuditingBeanFactoryPostProcessor.java
  8. +144 −163 src/main/java/org/springframework/data/jpa/domain/support/AuditingEntityListener.java
  9. +47 −56 src/main/java/org/springframework/data/jpa/repository/JpaRepository.java
  10. +38 −47 src/main/java/org/springframework/data/jpa/repository/JpaSpecificationExecutor.java
  11. +6 −8 src/main/java/org/springframework/data/jpa/repository/Modifying.java
  12. +2 −4 src/main/java/org/springframework/data/jpa/repository/Query.java
  13. +5 −7 src/main/java/org/springframework/data/jpa/repository/QueryHints.java
  14. +63 −86 src/main/java/org/springframework/data/jpa/repository/config/AuditingBeanDefinitionParser.java
  15. +95 −121 ...main/java/org/springframework/data/jpa/repository/config/JpaRepositoryConfigDefinitionParser.java
  16. +9 −12 src/main/java/org/springframework/data/jpa/repository/config/JpaRepositoryNameSpaceHandler.java
  17. +109 −127 src/main/java/org/springframework/data/jpa/repository/config/SimpleJpaRepositoryConfiguration.java
  18. +81 −93 src/main/java/org/springframework/data/jpa/repository/query/AbstractJpaQuery.java
  19. +9 −10 src/main/java/org/springframework/data/jpa/repository/query/AbstractStringBasedJpaQuery.java
  20. +58 −70 src/main/java/org/springframework/data/jpa/repository/query/CriteriaQueryParameterBinder.java
  21. +27 −30 src/main/java/org/springframework/data/jpa/repository/query/JpaCountQueryCreator.java
  22. +312 −373 src/main/java/org/springframework/data/jpa/repository/query/JpaQueryCreator.java
  23. +90 −110 src/main/java/org/springframework/data/jpa/repository/query/JpaQueryExecution.java
  24. +144 −177 src/main/java/org/springframework/data/jpa/repository/query/JpaQueryLookupStrategy.java
  25. +115 −134 src/main/java/org/springframework/data/jpa/repository/query/JpaQueryMethod.java
  26. +100 −115 src/main/java/org/springframework/data/jpa/repository/query/NamedQuery.java
  27. +92 −108 src/main/java/org/springframework/data/jpa/repository/query/ParameterBinder.java
  28. +153 −176 src/main/java/org/springframework/data/jpa/repository/query/PartTreeJpaQuery.java
  29. +15 −22 src/main/java/org/springframework/data/jpa/repository/query/QueryExtractor.java
  30. +232 −255 src/main/java/org/springframework/data/jpa/repository/query/QueryUtils.java
  31. +89 −107 src/main/java/org/springframework/data/jpa/repository/query/SimpleJpaQuery.java
  32. +16 −20 src/main/java/org/springframework/data/jpa/repository/support/JpaEntityInformation.java
  33. +44 −52 src/main/java/org/springframework/data/jpa/repository/support/JpaEntityInformationSupport.java
  34. +83 −96 src/main/java/org/springframework/data/jpa/repository/support/JpaMetamodelEntityInformation.java
  35. +34 −40 src/main/java/org/springframework/data/jpa/repository/support/JpaPersistableEntityInformation.java
  36. +106 −121 src/main/java/org/springframework/data/jpa/repository/support/JpaRepositoryFactory.java
  37. +53 −59 src/main/java/org/springframework/data/jpa/repository/support/JpaRepositoryFactoryBean.java
  38. +115 −126 src/main/java/org/springframework/data/jpa/repository/support/PersistenceProvider.java
  39. +164 −183 src/main/java/org/springframework/data/jpa/repository/support/QueryDslJpaRepository.java
  40. +68 −75 src/main/java/org/springframework/data/jpa/repository/support/QueryDslRepositorySupport.java
  41. +435 −481 src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java
  42. +22 −25 src/main/java/org/springframework/data/jpa/repository/utils/JpaClassUtils.java
  43. +32 −40 src/main/java/org/springframework/data/jpa/support/MergingPersistenceUnitManager.java
  44. +1 −2 src/test/java/org/springframework/data/jpa/domain/sample/Account.java
  45. +8 −11 src/test/java/org/springframework/data/jpa/domain/sample/AuditableRole.java
  46. +34 −42 src/test/java/org/springframework/data/jpa/domain/sample/AuditableUser.java
  47. +19 −24 src/test/java/org/springframework/data/jpa/domain/sample/AuditorAwareStub.java
  48. +53 −60 src/test/java/org/springframework/data/jpa/domain/sample/Role.java
  49. +22 −27 src/test/java/org/springframework/data/jpa/domain/sample/SampleEntity.java
  50. +55 −60 src/test/java/org/springframework/data/jpa/domain/sample/SampleEntityPK.java
  51. +0 −1 src/test/java/org/springframework/data/jpa/domain/sample/SpecialUser.java
  52. +234 −260 src/test/java/org/springframework/data/jpa/domain/sample/User.java
  53. +38 −47 src/test/java/org/springframework/data/jpa/domain/sample/UserSpecifications.java
  54. +17 −26 ...t/java/org/springframework/data/jpa/domain/support/AuditingBeanFactoryPostProcessorUnitTests.java
  55. +36 −43 src/test/java/org/springframework/data/jpa/domain/support/AuditingEntityListenerTests.java
  56. +75 −86 src/test/java/org/springframework/data/jpa/domain/support/AuditingEntityListenerUnitTests.java
  57. +21 −27 src/test/java/org/springframework/data/jpa/domain/support/AuditingNamespaceUnitTests.java
  58. +2 −5 src/test/java/org/springframework/data/jpa/repository/EclipseLinkNamespaceUserRepositoryTests.java
  59. +1 −3 src/test/java/org/springframework/data/jpa/repository/EclipseLinkUserRepositoryFinderTests.java
  60. +12 −16 src/test/java/org/springframework/data/jpa/repository/NamespaceUserRepositoryTests.java
  61. +12 −15 src/test/java/org/springframework/data/jpa/repository/ORMInfrastructureTests.java
  62. +1 −3 src/test/java/org/springframework/data/jpa/repository/OpenJpaNamespaceUserRepositoryTests.java
  63. +18 −21 src/test/java/org/springframework/data/jpa/repository/RoleRepositoryIntegrationTests.java
  64. +35 −40 src/test/java/org/springframework/data/jpa/repository/SimpleJpaParameterBindingTests.java
  65. +90 −109 src/test/java/org/springframework/data/jpa/repository/UserRepositoryFinderTests.java
  66. +487 −587 src/test/java/org/springframework/data/jpa/repository/UserRepositoryTests.java
  67. +15 −17 src/test/java/org/springframework/data/jpa/repository/config/AbstractRepositoryConfigTests.java
  68. +16 −23 src/test/java/org/springframework/data/jpa/repository/config/AuditingBeanDefinitionParserTests.java
  69. +31 −37 src/test/java/org/springframework/data/jpa/repository/config/CustomRepositoryFactoryConfigTests.java
  70. +10 −16 ...java/org/springframework/data/jpa/repository/config/JpaRepositoryConfigDefinitionParserTests.java
  71. +10 −16 src/test/java/org/springframework/data/jpa/repository/config/QueryLookupStrategyTests.java
  72. +0 −1 src/test/java/org/springframework/data/jpa/repository/config/RepositoryAutoConfigTests.java
  73. +0 −1 src/test/java/org/springframework/data/jpa/repository/config/RepositoryConfigTests.java
  74. +14 −17 src/test/java/org/springframework/data/jpa/repository/config/TypeFilterConfigTest.java
  75. +24 −29 src/test/java/org/springframework/data/jpa/repository/custom/CustomGenericJpaRepository.java
  76. +32 −40 src/test/java/org/springframework/data/jpa/repository/custom/CustomGenericJpaRepositoryFactory.java
  77. +12 −13 ...st/java/org/springframework/data/jpa/repository/custom/CustomGenericJpaRepositoryFactoryBean.java
  78. +10 −13 src/test/java/org/springframework/data/jpa/repository/custom/CustomGenericRepository.java
  79. +12 −16 src/test/java/org/springframework/data/jpa/repository/custom/UserCustomExtendedRepository.java
  80. +55 −65 src/test/java/org/springframework/data/jpa/repository/query/JpaQueryExecutionUnitTests.java
  81. +120 −176 src/test/java/org/springframework/data/jpa/repository/query/JpaQueryMethodUnitTests.java
  82. +22 −26 src/test/java/org/springframework/data/jpa/repository/query/NamedQueryUnitTests.java
  83. +96 −136 src/test/java/org/springframework/data/jpa/repository/query/ParameterBinderUnitTests.java
  84. +37 −47 src/test/java/org/springframework/data/jpa/repository/query/PartTreeJpaQueryIntegrationTests.java
  85. +79 −100 src/test/java/org/springframework/data/jpa/repository/query/QueryUtilsUnitTests.java
  86. +47 −60 src/test/java/org/springframework/data/jpa/repository/query/SimpleJpaQueryUnitTests.java
  87. +8 −10 src/test/java/org/springframework/data/jpa/repository/sample/AuditableUserRepository.java
  88. +0 −1 src/test/java/org/springframework/data/jpa/repository/sample/RoleRepository.java
  89. +145 −189 src/test/java/org/springframework/data/jpa/repository/sample/UserRepository.java
  90. +10 −12 src/test/java/org/springframework/data/jpa/repository/sample/UserRepositoryCustom.java
  91. +23 −27 src/test/java/org/springframework/data/jpa/repository/sample/UserRepositoryImpl.java
  92. +15 −20 src/test/java/org/springframework/data/jpa/repository/support/EntityManagerFactoryRefTests.java
  93. +19 −30 src/test/java/org/springframework/data/jpa/repository/support/EntityManagerFactoryRefUnitTests.java
  94. +26 −34 ...st/java/org/springframework/data/jpa/repository/support/JpaEntityInformationSupportUnitTests.java
  95. +34 −40 ...ava/org/springframework/data/jpa/repository/support/JpaPersistableEntityInformationUnitTests.java
  96. +101 −118 src/test/java/org/springframework/data/jpa/repository/support/JpaRepositoryFactoryBeanUnitTests.java
  97. +109 −141 src/test/java/org/springframework/data/jpa/repository/support/JpaRepositoryFactoryUnitTests.java
  98. +19 −26 src/test/java/org/springframework/data/jpa/repository/support/JpaRepositoryTests.java
  99. +1 −1 ...va/org/springframework/data/jpa/repository/support/QSimpleEntityPathResolverUnitTests_Sample.java
  100. +30 −41 src/test/java/org/springframework/data/jpa/repository/support/QueryDslJpaRepositoryTests.java
  101. +68 −80 src/test/java/org/springframework/data/jpa/repository/support/QueryDslRepositorySupportTests.java
  102. +63 −83 src/test/java/org/springframework/data/jpa/repository/support/TransactionalRepositoryTests.java
  103. +12 −15 src/test/java/org/springframework/data/jpa/support/MergingPersistenceUnitManagerUnitTests.java
View
4 .gitignore
@@ -2,4 +2,6 @@ target/
.settings/
.project
.classpath
-.springBeans
+.springBeans
+.sonar4clipse
+*.sonar4clipseExternals
View
291 formatting.xml
@@ -0,0 +1,291 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<profiles version="12">
+<profile kind="CodeFormatterProfile" name="Spring Data" version="12">
+<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
+<setting id="org.eclipse.jdt.core.compiler.source" value="1.7"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="2"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="0"/>
+<setting id="org.eclipse.jdt.core.compiler.problem.assertIdentifier" value="error"/>
+<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="tab"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.compiler.problem.enumIdentifier" value="error"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="2"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
+<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.7"/>
+<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode" value="enabled"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="120"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.wrap_before_binary_operator" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/>
+<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.7"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="80"/>
+<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
+</profile>
+</profiles>
View
219 src/main/java/org/springframework/data/jpa/domain/AbstractAuditable.java
@@ -26,126 +26,115 @@
import org.joda.time.DateTime;
import org.springframework.data.domain.Auditable;
-
/**
- * Abstract base class for auditable entities. Stores the audition values in
- * persistent fields.
+ * Abstract base class for auditable entities. Stores the audition values in persistent fields.
*
* @author Oliver Gierke
* @param <U> the auditing type. Typically some kind of user.
* @param <PK> the type of the auditing type's idenifier
*/
@MappedSuperclass
-public abstract class AbstractAuditable<U, PK extends Serializable> extends
- AbstractPersistable<PK> implements Auditable<U, PK> {
-
- private static final long serialVersionUID = 141481953116476081L;
-
- @OneToOne
- private U createdBy;
-
- @Temporal(TemporalType.TIMESTAMP)
- private Date createdDate;
-
- @OneToOne
- private U lastModifiedBy;
-
- @Temporal(TemporalType.TIMESTAMP)
- private Date lastModifiedDate;
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.springframework.data.domain.Auditable#getCreatedBy()
- */
- public U getCreatedBy() {
-
- return createdBy;
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.springframework.data.domain.Auditable#setCreatedBy(java.lang.Object)
- */
- public void setCreatedBy(final U createdBy) {
-
- this.createdBy = createdBy;
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.springframework.data.domain.Auditable#getCreatedDate()
- */
- public DateTime getCreatedDate() {
-
- return null == createdDate ? null : new DateTime(createdDate);
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.springframework.data.domain.Auditable#setCreatedDate(org.joda.time
- * .DateTime)
- */
- public void setCreatedDate(final DateTime createdDate) {
-
- this.createdDate = null == createdDate ? null : createdDate.toDate();
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.springframework.data.domain.Auditable#getLastModifiedBy()
- */
- public U getLastModifiedBy() {
-
- return lastModifiedBy;
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.springframework.data.domain.Auditable#setLastModifiedBy(java.lang
- * .Object)
- */
- public void setLastModifiedBy(final U lastModifiedBy) {
-
- this.lastModifiedBy = lastModifiedBy;
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.springframework.data.domain.Auditable#getLastModifiedDate()
- */
- public DateTime getLastModifiedDate() {
-
- return null == lastModifiedDate ? null : new DateTime(lastModifiedDate);
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.springframework.data.domain.Auditable#setLastModifiedDate(org.joda
- * .time.DateTime)
- */
- public void setLastModifiedDate(final DateTime lastModifiedDate) {
-
- this.lastModifiedDate =
- null == lastModifiedDate ? null : lastModifiedDate.toDate();
- }
+public abstract class AbstractAuditable<U, PK extends Serializable> extends AbstractPersistable<PK> implements
+ Auditable<U, PK> {
+
+ private static final long serialVersionUID = 141481953116476081L;
+
+ @OneToOne
+ private U createdBy;
+
+ @Temporal(TemporalType.TIMESTAMP)
+ private Date createdDate;
+
+ @OneToOne
+ private U lastModifiedBy;
+
+ @Temporal(TemporalType.TIMESTAMP)
+ private Date lastModifiedDate;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.springframework.data.domain.Auditable#getCreatedBy()
+ */
+ public U getCreatedBy() {
+
+ return createdBy;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.springframework.data.domain.Auditable#setCreatedBy(java.lang.Object)
+ */
+ public void setCreatedBy(final U createdBy) {
+
+ this.createdBy = createdBy;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.springframework.data.domain.Auditable#getCreatedDate()
+ */
+ public DateTime getCreatedDate() {
+
+ return null == createdDate ? null : new DateTime(createdDate);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.springframework.data.domain.Auditable#setCreatedDate(org.joda.time
+ * .DateTime)
+ */
+ public void setCreatedDate(final DateTime createdDate) {
+
+ this.createdDate = null == createdDate ? null : createdDate.toDate();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.springframework.data.domain.Auditable#getLastModifiedBy()
+ */
+ public U getLastModifiedBy() {
+
+ return lastModifiedBy;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.springframework.data.domain.Auditable#setLastModifiedBy(java.lang
+ * .Object)
+ */
+ public void setLastModifiedBy(final U lastModifiedBy) {
+
+ this.lastModifiedBy = lastModifiedBy;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.springframework.data.domain.Auditable#getLastModifiedDate()
+ */
+ public DateTime getLastModifiedDate() {
+
+ return null == lastModifiedDate ? null : new DateTime(lastModifiedDate);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.springframework.data.domain.Auditable#setLastModifiedDate(org.joda
+ * .time.DateTime)
+ */
+ public void setLastModifiedDate(final DateTime lastModifiedDate) {
+
+ this.lastModifiedDate = null == lastModifiedDate ? null : lastModifiedDate.toDate();
+ }
}
View
190 src/main/java/org/springframework/data/jpa/domain/AbstractPersistable.java
@@ -24,110 +24,100 @@
import org.springframework.data.domain.Persistable;
-
/**
- * Abstract base class for entities. Allows parameterization of id type, chooses
- * auto-generation and implements {@link #equals(Object)} and
- * {@link #hashCode()} based on that id.
+ * Abstract base class for entities. Allows parameterization of id type, chooses auto-generation and implements
+ * {@link #equals(Object)} and {@link #hashCode()} based on that id.
*
* @author Oliver Gierke
* @param <PK> the the of the entity
*/
@MappedSuperclass
-public abstract class AbstractPersistable<PK extends Serializable> implements
- Persistable<PK> {
-
- private static final long serialVersionUID = -5554308939380869754L;
-
- @Id
- @GeneratedValue(strategy = GenerationType.AUTO)
- private PK id;
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.springframework.data.domain.Persistable#getId()
- */
- public PK getId() {
-
- return id;
- }
-
-
- /**
- * Sets the id of the entity.
- *
- * @param id the id to set
- */
- protected void setId(final PK id) {
-
- this.id = id;
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.springframework.data.domain.Persistable#isNew()
- */
- public boolean isNew() {
-
- return null == getId();
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
-
- return String.format("Entity of type %s with id: %s", this.getClass()
- .getName(), getId());
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
-
- if (null == obj) {
- return false;
- }
-
- if (this == obj) {
- return true;
- }
-
- if (!getClass().equals(obj.getClass())) {
- return false;
- }
-
- AbstractPersistable<?> that = (AbstractPersistable<?>) obj;
-
- return null == this.getId() ? false : this.getId().equals(that.getId());
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
-
- int hashCode = 17;
-
- hashCode += null == getId() ? 0 : getId().hashCode() * 31;
-
- return hashCode;
- }
+public abstract class AbstractPersistable<PK extends Serializable> implements Persistable<PK> {
+
+ private static final long serialVersionUID = -5554308939380869754L;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private PK id;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.springframework.data.domain.Persistable#getId()
+ */
+ public PK getId() {
+
+ return id;
+ }
+
+ /**
+ * Sets the id of the entity.
+ *
+ * @param id the id to set
+ */
+ protected void setId(final PK id) {
+
+ this.id = id;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.springframework.data.domain.Persistable#isNew()
+ */
+ public boolean isNew() {
+
+ return null == getId();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+
+ return String.format("Entity of type %s with id: %s", this.getClass().getName(), getId());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+
+ if (null == obj) {
+ return false;
+ }
+
+ if (this == obj) {
+ return true;
+ }
+
+ if (!getClass().equals(obj.getClass())) {
+ return false;
+ }
+
+ AbstractPersistable<?> that = (AbstractPersistable<?>) obj;
+
+ return null == this.getId() ? false : this.getId().equals(that.getId());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+
+ int hashCode = 17;
+
+ hashCode += null == getId() ? 0 : getId().hashCode() * 31;
+
+ return hashCode;
+ }
}
View
20 src/main/java/org/springframework/data/jpa/domain/Specification.java
@@ -20,22 +20,20 @@
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
-
/**
* Specification in the sense of Domain Driven Design.
*
* @author Oliver Gierke
*/
public interface Specification<T> {
- /**
- * Creates a WHERE clause for a query of the referenced entity in form of a
- * {@link Predicate} for the given {@link Root} and {@link CriteriaQuery}.
- *
- * @param root
- * @param query
- * @return a {@link Predicate}, must not be {@literal null}.
- */
- Predicate toPredicate(Root<T> root, CriteriaQuery<?> query,
- CriteriaBuilder cb);
+ /**
+ * Creates a WHERE clause for a query of the referenced entity in form of a {@link Predicate} for the given
+ * {@link Root} and {@link CriteriaQuery}.
+ *
+ * @param root
+ * @param query
+ * @return a {@link Predicate}, must not be {@literal null}.
+ */
+ Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder cb);
}
View
191 src/main/java/org/springframework/data/jpa/domain/Specifications.java
@@ -20,114 +20,99 @@
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
-
/**
* Helper class to easily combine {@link Specification} instances.
*
* @author Oliver Gierke
*/
public class Specifications<T> implements Specification<T> {
- private final Specification<T> spec;
-
-
- /**
- * Creates a new {@link Specifications} wrapper for the given
- * {@link Specification}.
- *
- * @param spec
- */
- private Specifications(Specification<T> spec) {
-
- this.spec = spec;
- }
-
-
- /**
- * Simple static factory method to add some syntactic sugar around a
- * {@link Specification}.
- *
- * @param <T>
- * @param spec
- * @return
- */
- public static <T> Specifications<T> where(Specification<T> spec) {
-
- return new Specifications<T>(spec);
- }
-
-
- /**
- * ANDs the given {@link Specification} to the current one.
- *
- * @param other
- * @return
- */
- public Specifications<T> and(final Specification<T> other) {
-
- return new Specifications<T>(new Specification<T>() {
-
- public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query,
- CriteriaBuilder builder) {
-
- return builder.and(spec.toPredicate(root, query, builder),
- other.toPredicate(root, query, builder));
- }
- });
- }
-
-
- /**
- * ORs the given specification to the current one.
- *
- * @param other
- * @return
- */
- public Specifications<T> or(final Specification<T> other) {
-
- return new Specifications<T>(new Specification<T>() {
-
- public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query,
- CriteriaBuilder builder) {
-
- return builder.or(spec.toPredicate(root, query, builder),
- other.toPredicate(root, query, builder));
- }
- });
- }
-
-
- /**
- * Negates the given {@link Specification}.
- *
- * @param <T>
- * @param spec
- * @return
- */
- public static <T> Specifications<T> not(final Specification<T> spec) {
-
- return new Specifications<T>(spec) {
-
- @Override
- public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query,
- CriteriaBuilder builder) {
-
- return builder.not(spec.toPredicate(root, query, builder));
- }
- };
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.springframework.data.jpa.domain.Specification#toPredicate(javax.
- * persistence.criteria.Root, javax.persistence.criteria.CriteriaQuery,
- * javax.persistence.criteria.CriteriaBuilder)
- */
- public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query,
- CriteriaBuilder builder) {
-
- return spec.toPredicate(root, query, builder);
- }
+ private final Specification<T> spec;
+
+ /**
+ * Creates a new {@link Specifications} wrapper for the given {@link Specification}.
+ *
+ * @param spec
+ */
+ private Specifications(Specification<T> spec) {
+
+ this.spec = spec;
+ }
+
+ /**
+ * Simple static factory method to add some syntactic sugar around a {@link Specification}.
+ *
+ * @param <T>
+ * @param spec
+ * @return
+ */
+ public static <T> Specifications<T> where(Specification<T> spec) {
+
+ return new Specifications<T>(spec);
+ }
+
+ /**
+ * ANDs the given {@link Specification} to the current one.
+ *
+ * @param other
+ * @return
+ */
+ public Specifications<T> and(final Specification<T> other) {
+
+ return new Specifications<T>(new Specification<T>() {
+
+ public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
+
+ return builder.and(spec.toPredicate(root, query, builder), other.toPredicate(root, query, builder));
+ }
+ });
+ }
+
+ /**
+ * ORs the given specification to the current one.
+ *
+ * @param other
+ * @return
+ */
+ public Specifications<T> or(final Specification<T> other) {
+
+ return new Specifications<T>(new Specification<T>() {
+
+ public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
+
+ return builder.or(spec.toPredicate(root, query, builder), other.toPredicate(root, query, builder));
+ }
+ });
+ }
+
+ /**
+ * Negates the given {@link Specification}.
+ *
+ * @param <T>
+ * @param spec
+ * @return
+ */
+ public static <T> Specifications<T> not(final Specification<T> spec) {
+
+ return new Specifications<T>(spec) {
+
+ @Override
+ public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
+
+ return builder.not(spec.toPredicate(root, query, builder));
+ }
+ };
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.springframework.data.jpa.domain.Specification#toPredicate(javax.
+ * persistence.criteria.Root, javax.persistence.criteria.CriteriaQuery,
+ * javax.persistence.criteria.CriteriaBuilder)
+ */
+ public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
+
+ return spec.toPredicate(root, query, builder);
+ }
}
View
130 ...in/java/org/springframework/data/jpa/domain/support/AuditingBeanFactoryPostProcessor.java
@@ -27,82 +27,68 @@
import org.springframework.data.domain.AuditorAware;
import org.springframework.util.StringUtils;
-
/**
* {@link BeanFactoryPostProcessor} to add a {@code depends-on} from a
* {@link org.springframework.orm.jpa.LocalEntityManagerFactoryBean} or
- * {@link org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean}
- * towards the aspect bean configured via
- * {@code &lt;context:spring-configured&gt;}. This has to be done to ensure the
- * aspect is up and running <em>before</em> the
- * {@link javax.persistence.EntityManagerFactory} gets created as this already
- * instantiates entity listeners and we need to get injection into
- * {@link org.springframework.beans.factory.annotation.Configurable} to work in
- * them.
+ * {@link org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean} towards the aspect bean configured via
+ * {@code &lt;context:spring-configured&gt;}. This has to be done to ensure the aspect is up and running <em>before</em>
+ * the {@link javax.persistence.EntityManagerFactory} gets created as this already instantiates entity listeners and we
+ * need to get injection into {@link org.springframework.beans.factory.annotation.Configurable} to work in them.
*
* @author Oliver Gierke
*/
-public class AuditingBeanFactoryPostProcessor implements
- BeanFactoryPostProcessor {
-
- static final String BEAN_CONFIGURER_ASPECT_BEAN_NAME =
- "org.springframework.context.config.internalBeanConfigurerAspect";
-
- private static final String JPA_PACKAGE = "org.springframework.orm.jpa.";
- private static final List<String> CLASSES_TO_DEPEND = Arrays.asList(
- JPA_PACKAGE + "LocalContainerEntityManagerFactoryBean", JPA_PACKAGE
- + "LocalEntityManagerFactoryBean");
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.springframework.beans.factory.config.BeanFactoryPostProcessor#
- * postProcessBeanFactory
- * (org.springframework.beans.factory.config.ConfigurableListableBeanFactory
- * )
- */
- public void postProcessBeanFactory(
- ConfigurableListableBeanFactory beanFactory) {
-
- if (!isSpringConfigured(beanFactory)) {
- return;
- }
-
- for (String beanName : beanFactory.getBeanDefinitionNames()) {
-
- BeanDefinition definition = beanFactory.getBeanDefinition(beanName);
-
- if (CLASSES_TO_DEPEND.contains(definition.getBeanClassName())) {
- definition.setDependsOn(StringUtils.addStringToArray(
- definition.getDependsOn(),
- BEAN_CONFIGURER_ASPECT_BEAN_NAME));
- }
- }
-
- for (String beanName : BeanFactoryUtils
- .beanNamesForTypeIncludingAncestors(beanFactory,
- AuditorAware.class, true, false)) {
- BeanDefinition definition = beanFactory.getBeanDefinition(beanName);
- definition.setLazyInit(true);
- }
- }
-
-
- /**
- * Returns whether we have a bean factory for which
- * {@code &lt;context:spring-configured&gt;} was activated.
- *
- * @param factory
- * @return
- */
- private boolean isSpringConfigured(BeanFactory factory) {
-
- try {
- factory.getBean(BEAN_CONFIGURER_ASPECT_BEAN_NAME);
- return true;
- } catch (NoSuchBeanDefinitionException e) {
- return false;
- }
- }
+public class AuditingBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
+
+ static final String BEAN_CONFIGURER_ASPECT_BEAN_NAME = "org.springframework.context.config.internalBeanConfigurerAspect";
+
+ private static final String JPA_PACKAGE = "org.springframework.orm.jpa.";
+ private static final List<String> CLASSES_TO_DEPEND = Arrays.asList(JPA_PACKAGE
+ + "LocalContainerEntityManagerFactoryBean", JPA_PACKAGE + "LocalEntityManagerFactoryBean");
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.springframework.beans.factory.config.BeanFactoryPostProcessor#
+ * postProcessBeanFactory
+ * (org.springframework.beans.factory.config.ConfigurableListableBeanFactory
+ * )
+ */
+ public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
+
+ if (!isSpringConfigured(beanFactory)) {
+ return;
+ }
+
+ for (String beanName : beanFactory.getBeanDefinitionNames()) {
+
+ BeanDefinition definition = beanFactory.getBeanDefinition(beanName);
+
+ if (CLASSES_TO_DEPEND.contains(definition.getBeanClassName())) {
+ definition.setDependsOn(StringUtils.addStringToArray(definition.getDependsOn(),
+ BEAN_CONFIGURER_ASPECT_BEAN_NAME));
+ }
+ }
+
+ for (String beanName : BeanFactoryUtils.beanNamesForTypeIncludingAncestors(beanFactory, AuditorAware.class, true,
+ false)) {
+ BeanDefinition definition = beanFactory.getBeanDefinition(beanName);
+ definition.setLazyInit(true);
+ }
+ }
+
+ /**
+ * Returns whether we have a bean factory for which {@code &lt;context:spring-configured&gt;} was activated.
+ *
+ * @param factory
+ * @return
+ */
+ private boolean isSpringConfigured(BeanFactory factory) {
+
+ try {
+ factory.getBean(BEAN_CONFIGURER_ASPECT_BEAN_NAME);
+ return true;
+ } catch (NoSuchBeanDefinitionException e) {
+ return false;
+ }
+ }
}
View
307 src/main/java/org/springframework/data/jpa/domain/support/AuditingEntityListener.java
@@ -27,11 +27,9 @@
import org.springframework.data.domain.AuditorAware;
import org.springframework.util.Assert;
-
/**
- * JPA entity listener to capture auditing information on persiting and updating
- * entities. To get this one flying be sure you configure it as entity listener
- * in your {@code orm.xml} as follows:
+ * JPA entity listener to capture auditing information on persiting and updating entities. To get this one flying be
+ * sure you configure it as entity listener in your {@code orm.xml} as follows:
*
* <pre>
* &lt;persistence-unit-metadata&gt;
@@ -54,167 +52,150 @@
@Configurable
public class AuditingEntityListener<T> implements InitializingBean {
- private static final Logger LOG = LoggerFactory
- .getLogger(AuditingEntityListener.class);
-
- private AuditorAware<T> auditorAware;
-
- private boolean dateTimeForNow = true;
- private boolean modifyOnCreation = true;
-
-
- /**
- * Setter to inject a {@code AuditorAware} component to retrieve the current
- * auditor.
- *
- * @param auditorAware the auditorAware to set
- */
- public void setAuditorAware(final AuditorAware<T> auditorAware) {
-
- Assert.notNull(auditorAware);
- this.auditorAware = auditorAware;
- }
-
-
- /**
- * Setter do determine if {@link Auditable#setCreatedDate(DateTime)} and
- * {@link Auditable#setLastModifiedDate(DateTime)} shall be filled with the
- * current Java time. Defaults to {@code true}. One might set this to
- * {@code false} to use database features to set entity time.
- *
- * @param dateTimeForNow the dateTimeForNow to set
- */
- public void setDateTimeForNow(boolean dateTimeForNow) {
-
- this.dateTimeForNow = dateTimeForNow;
- }
-
-
- /**
- * Set this to false if you want to treat entity creation as modification
- * and thus set the current date as modification date, too. Defaults to
- * {@code true}.
- *
- * @param modifyOnCreation if modification information shall be set on
- * creation, too
- */
- public void setModifyOnCreation(final boolean modifyOnCreation) {
-
- this.modifyOnCreation = modifyOnCreation;
- }
-
-
- /**
- * Sets modification and creation date and auditor on the target object in
- * case it implements {@link Auditable} on persist events.
- *
- * @param target
- */
- @PrePersist
- public void touchForCreate(Object target) {
-
- touch(target, true);
- }
-
-
- /**
- * Sets modification and creation date and auditor on the target object in
- * case it implements {@link Auditable} on update events.
- *
- * @param target
- */
- @PreUpdate
- public void touchForUpdate(Object target) {
-
- touch(target, false);
- }
-
-
- private void touch(Object target, boolean isNew) {
-
- if (!(target instanceof Auditable)) {
- return;
- }
-
- @SuppressWarnings("unchecked")
- Auditable<T, ?> auditable = (Auditable<T, ?>) target;
-
- T auditor = touchAuditor(auditable, isNew);
- DateTime now = dateTimeForNow ? touchDate(auditable, isNew) : null;
-
- Object defaultedNow = now == null ? "not set" : now;
- Object defaultedAuditor = auditor == null ? "unknown" : auditor;
-
- LOG.debug("Touched {} - Last modification at {} by {}", new Object[] {
- auditable, defaultedNow, defaultedAuditor });
- }
-
-
- /**
- * Sets modifying and creating auditioner. Creating auditioner is only set
- * on new auditables.
- *
- * @param auditable
- * @return
- */
- private T touchAuditor(final Auditable<T, ?> auditable, boolean isNew) {
-
- if (null == auditorAware) {
- return null;
- }
-
- T auditor = auditorAware.getCurrentAuditor();
-
- if (isNew) {
-
- auditable.setCreatedBy(auditor);
-
- if (!modifyOnCreation) {
- return auditor;
- }
- }
-
- auditable.setLastModifiedBy(auditor);
-
- return auditor;
- }
-
-
- /**
- * Touches the auditable regarding modification and creation date. Creation
- * date is only set on new auditables.
- *
- * @param auditable
- * @return
- */
- private DateTime touchDate(final Auditable<T, ?> auditable, boolean isNew) {
-
- DateTime now = new DateTime();
-
- if (isNew) {
- auditable.setCreatedDate(now);
-
- if (!modifyOnCreation) {
- return now;
- }
- }
-
- auditable.setLastModifiedDate(now);
+ private static final Logger LOG = LoggerFactory.getLogger(AuditingEntityListener.class);
- return now;
- }
+ private AuditorAware<T> auditorAware;
+
+ private boolean dateTimeForNow = true;
+ private boolean modifyOnCreation = true;
+
+ /**
+ * Setter to inject a {@code AuditorAware} component to retrieve the current auditor.
+ *
+ * @param auditorAware the auditorAware to set
+ */
+ public void setAuditorAware(final AuditorAware<T> auditorAware) {
+ Assert.notNull(auditorAware);
+ this.auditorAware = auditorAware;
+ }
+
+ /**
+ * Setter do determine if {@link Auditable#setCreatedDate(DateTime)} and
+ * {@link Auditable#setLastModifiedDate(DateTime)} shall be filled with the current Java time. Defaults to
+ * {@code true}. One might set this to {@code false} to use database features to set entity time.
+ *
+ * @param dateTimeForNow the dateTimeForNow to set
+ */
+ public void setDateTimeForNow(boolean dateTimeForNow) {
+
+ this.dateTimeForNow = dateTimeForNow;
+ }
- /*
- * (non-Javadoc)
- *
- * @see
- * org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
- */
- public void afterPropertiesSet() {
+ /**
+ * Set this to false if you want to treat entity creation as modification and thus set the current date as
+ * modification date, too. Defaults to {@code true}.
+ *
+ * @param modifyOnCreation if modification information shall be set on creation, too
+ */
+ public void setModifyOnCreation(final boolean modifyOnCreation) {
- if (auditorAware == null) {
- LOG.debug("No AuditorAware set! Auditing will not be applied!");
- }
- }
+ this.modifyOnCreation = modifyOnCreation;
+ }
+
+ /**
+ * Sets modification and creation date and auditor on the target object in case it implements {@link Auditable} on
+ * persist events.
+ *
+ * @param target
+ */
+ @PrePersist
+ public void touchForCreate(Object target) {
+
+ touch(target, true);
+ }
+
+ /**
+ * Sets modification and creation date and auditor on the target object in case it implements {@link Auditable} on
+ * update events.
+ *
+ * @param target
+ */
+ @PreUpdate
+ public void touchForUpdate(Object target) {
+
+ touch(target, false);
+ }
+
+ private void touch(Object target, boolean isNew) {
+
+ if (!(target instanceof Auditable)) {
+ return;
+ }
+
+ @SuppressWarnings("unchecked")
+ Auditable<T, ?> auditable = (Auditable<T, ?>) target;
+
+ T auditor = touchAuditor(auditable, isNew);
+ DateTime now = dateTimeForNow ? touchDate(auditable, isNew) : null;
+
+ Object defaultedNow = now == null ? "not set" : now;
+ Object defaultedAuditor = auditor == null ? "unknown" : auditor;
+
+ LOG.debug("Touched {} - Last modification at {} by {}", new Object[] { auditable, defaultedNow, defaultedAuditor });
+ }
+
+ /**
+ * Sets modifying and creating auditioner. Creating auditioner is only set on new auditables.
+ *
+ * @param auditable
+ * @return
+ */
+ private T touchAuditor(final Auditable<T, ?> auditable, boolean isNew) {
+
+ if (null == auditorAware) {
+ return null;
+ }
+
+ T auditor = auditorAware.getCurrentAuditor();
+
+ if (isNew) {
+
+ auditable.setCreatedBy(auditor);
+
+ if (!modifyOnCreation) {
+ return auditor;
+ }
+ }
+
+ auditable.setLastModifiedBy(auditor);
+
+ return auditor;
+ }
+
+ /**
+ * Touches the auditable regarding modification and creation date. Creation date is only set on new auditables.
+ *
+ * @param auditable
+ * @return
+ */
+ private DateTime touchDate(final Auditable<T, ?> auditable, boolean isNew) {
+
+ DateTime now = new DateTime();
+
+ if (isNew) {
+ auditable.setCreatedDate(now);
+
+ if (!modifyOnCreation) {
+ return now;
+ }
+ }
+
+ auditable.setLastModifiedDate(now);
+
+ return now;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
+ */
+ public void afterPropertiesSet() {
+
+ if (auditorAware == null) {
+ LOG.debug("No AuditorAware set! Auditing will not be applied!");
+ }
+ }
}
View
103 src/main/java/org/springframework/data/jpa/repository/JpaRepository.java
@@ -23,64 +23,55 @@
import org.springframework.data.domain.Sort;
import org.springframework.data.repository.PagingAndSortingRepository;
-
/**
- * JPA specific extension of
- * {@link org.springframework.data.repository.Repository}.
+ * JPA specific extension of {@link org.springframework.data.repository.Repository}.
*
* @author Oliver Gierke
*/
-public interface JpaRepository<T, ID extends Serializable> extends
- PagingAndSortingRepository<T, ID> {
-
- /*
- * (non-Javadoc)
- *
- * @see org.springframework.data.repository.Repository#findAll()
- */
- List<T> findAll();
-
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.springframework.data.repository.PagingAndSortingRepository#findAll
- * (org.springframework.data.domain.Sort)
- */
- List<T> findAll(Sort sort);
-
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.springframework.data.repository.Repository#save(java.lang.Iterable)
- */
- List<T> save(Iterable<? extends T> entities);
-
-
- /**
- * Flushes all pending changes to the database.
- */
- void flush();
-
-
- /**
- * Saves an entity and flushes changes instantly.
- *
- * @param entity
- * @return the saved entity
- */
- T saveAndFlush(T entity);
-
-
- /**
- * Deletes the given entities in a batch which means it will create a single
- * {@link Query}. Assume that we will clear the {@link EntityManager} after
- * the call.
- *
- * @param entities
- */
- void deleteInBatch(Iterable<T> entities);
+public interface JpaRepository<T, ID extends Serializable> extends PagingAndSortingRepository<T, ID> {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.springframework.data.repository.Repository#findAll()
+ */
+ List<T> findAll();
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.springframework.data.repository.PagingAndSortingRepository#findAll
+ * (org.springframework.data.domain.Sort)
+ */
+ List<T> findAll(Sort sort);
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.springframework.data.repository.Repository#save(java.lang.Iterable)
+ */
+ List<T> save(Iterable<? extends T> entities);
+
+ /**
+ * Flushes all pending changes to the database.
+ */
+ void flush();
+
+ /**
+ * Saves an entity and flushes changes instantly.
+ *
+ * @param entity
+ * @return the saved entity
+ */
+ T saveAndFlush(T entity);
+
+ /**
+ * Deletes the given entities in a batch which means it will create a single {@link Query}. Assume that we will clear
+ * the {@link EntityManager} after the call.
+ *
+ * @param entities
+ */
+ void deleteInBatch(Iterable<T> entities);
}
View
85 src/main/java/org/springframework/data/jpa/repository/JpaSpecificationExecutor.java
@@ -22,61 +22,52 @@
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
-
/**
- * Interface to allow execution of {@link Specification}s based on the JPA
- * criteria API.
+ * Interface to allow execution of {@link Specification}s based on the JPA criteria API.
*
* @author Oliver Gierke
*/
public interface JpaSpecificationExecutor<T> {
- /**
- * Returns a single entity matching the given {@link Specification}.
- *
- * @param spec
- * @return
- */
- T findOne(Specification<T> spec);
-
-
- /**
- * Returns all entities matching the given {@link Specification}.
- *
- * @param spec
- * @return
- */
- List<T> findAll(Specification<T> spec);
-
-
- /**
- * Returns a {@link Page} of entities matching the given
- * {@link Specification}.
- *
- * @param spec
- * @param pageable
- * @return
- */
- Page<T> findAll(Specification<T> spec, Pageable pageable);
+ /**
+ * Returns a single entity matching the given {@link Specification}.
+ *
+ * @param spec
+ * @return
+ */
+ T findOne(Specification<T> spec);
+ /**
+ * Returns all entities matching the given {@link Specification}.
+ *
+ * @param spec
+ * @return
+ */
+ List<T> findAll(Specification<T> spec);
- /**
- * Returns all entities matching the given {@link Specification} and
- * {@link Sort}.
- *
- * @param spec
- * @param sort
- * @return
- */
- List<T> findAll(Specification<T> spec, Sort sort);
+ /**
+ * Returns a {@link Page} of entities matching the given {@link Specification}.
+ *
+ * @param spec
+ * @param pageable
+ * @return
+ */
+ Page<T> findAll(Specification<T> spec, Pageable pageable);
+ /**
+ * Returns all entities matching the given {@link Specification} and {@link Sort}.
+ *
+ * @param spec
+ * @param sort
+ * @return
+ */
+ List<T> findAll(Specification<T> spec, Sort sort);
- /**
- * Returns the number of instances that the given {@link Specification} will
- * return.
- *
- * @param spec the {@link Specification} to count instances for
- * @return the number of instances
- */
- long count(Specification<T> spec);
+ /**
+ * Returns the number of instances that the given {@link Specification} will return.
+ *
+ * @param spec the {@link Specification} to count instances for
+ * @return the number of instances
+ */
+ long count(Specification<T> spec);
}
View
14 src/main/java/org/springframework/data/jpa/repository/Modifying.java
@@ -21,7 +21,6 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-
/**
* Indicates a method should be regarded as modifying query.
*
@@ -32,11 +31,10 @@
@Documented
public @interface Modifying {
- /**
- * Defines whether we should clear the underlying persistence context after
- * excuting the modifying query.
- *
- * @return
- */
- boolean clearAutomatically() default false;
+ /**
+ * Defines whether we should clear the underlying persistence context after excuting the modifying query.
+ *
+ * @return
+ */
+ boolean clearAutomatically() default false;
}
View
6 src/main/java/org/springframework/data/jpa/repository/Query.java
@@ -21,7 +21,6 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-
/**
* Annotation to declare finder queries directly on repository methods.
*
@@ -32,8 +31,7 @@
@Documented
public @interface Query {
- String value() default "";
-
+ String value() default "";
- String countQuery() default "";
+ String countQuery() default "";
}
View
12 src/main/java/org/springframework/data/jpa/repository/QueryHints.java
@@ -22,19 +22,17 @@
import javax.persistence.QueryHint;
-
/**
- * Wrapper annotation to allow {@link QueryHint} annotations to be bound to
- * methods. It will be evaluated when using {@link Query} on a query method or
- * if you derive the query from the method name. If you rely on named queries
- * either use the XML or annotation based way to declare {@link QueryHint}s in
- * combination with the actual named query declaration.
+ * Wrapper annotation to allow {@link QueryHint} annotations to be bound to methods. It will be evaluated when using
+ * {@link Query} on a query method or if you derive the query from the method name. If you rely on named queries either
+ * use the XML or annotation based way to declare {@link QueryHint}s in combination with the actual named query
+ * declaration.
*
* @author Oliver Gierke
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface QueryHints {
- QueryHint[] value() default {};
+ QueryHint[] value() default {};
}
View
149 ...ain/java/org/springframework/data/jpa/repository/config/AuditingBeanDefinitionParser.java
@@ -29,117 +29,94 @@
import org.springframework.util.StringUtils;
import org.w3c.dom.Element;
-
/**
- * {@link BeanDefinitionParser} for the {@code auditing} element. Sets up an
- * AudE
+ * {@link BeanDefinitionParser} for the {@code auditing} element. Sets up an AudE
*
* @author Oliver Gierke
*/
public class AuditingBeanDefinitionParser implements BeanDefinitionParser {
- static final String AUDITING_ENTITY_LISTENER_CLASS_NAME =
- "org.springframework.data.jpa.domain.support.AuditingEntityListener";
- private static final String AUDITING_BFPP_CLASS_NAME =
- "org.springframework.data.jpa.domain.support.AuditingBeanFactoryPostProcessor";
-
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.springframework.beans.factory.xml.BeanDefinitionParser#parse(org.
- * w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext)
- */
- public BeanDefinition parse(Element element, ParserContext parser) {
-
- new SpringConfiguredBeanDefinitionParser().parse(element, parser);
-
- BeanDefinitionBuilder builder =
- rootBeanDefinition(AUDITING_ENTITY_LISTENER_CLASS_NAME);
- builder.setScope("prototype");
+ static final String AUDITING_ENTITY_LISTENER_CLASS_NAME = "org.springframework.data.jpa.domain.support.AuditingEntityListener";
+ private static final String AUDITING_BFPP_CLASS_NAME = "org.springframework.data.jpa.domain.support.AuditingBeanFactoryPostProcessor";
- String auditorAwareRef = element.getAttribute("auditor-aware-ref");
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.springframework.beans.factory.xml.BeanDefinitionParser#parse(org.
+ * w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext)
+ */
+ public BeanDefinition parse(Element element, ParserContext parser) {
- if (StringUtils.hasText(auditorAwareRef)) {
- builder.addPropertyValue("auditorAware",
- createLazyInitTargetSourceBeanDefinition(auditorAwareRef));
- }
+ new SpringConfiguredBeanDefinitionParser().parse(element, parser);
- builder.addPropertyValue("dateTimeForNow",
- element.getAttribute("set-dates"));
+ BeanDefinitionBuilder builder = rootBeanDefinition(AUDITING_ENTITY_LISTENER_CLASS_NAME);
+ builder.setScope("prototype");
- registerInfrastructureBeanWithId(builder.getRawBeanDefinition(),
- AUDITING_ENTITY_LISTENER_CLASS_NAME, parser, element);
+ String auditorAwareRef = element.getAttribute("auditor-aware-ref");
- RootBeanDefinition def = new RootBeanDefinition();
- def.setBeanClassName(AUDITING_BFPP_CLASS_NAME);
- registerInfrastructureBeanWithId(def, AUDITING_BFPP_CLASS_NAME, parser,
- element);
+ if (StringUtils.hasText(auditorAwareRef)) {
+ builder.addPropertyValue("auditorAware", createLazyInitTargetSourceBeanDefinition(auditorAwareRef));
+ }
- return null;
- }
+ builder.addPropertyValue("dateTimeForNow", element.getAttribute("set-dates"));
+ registerInfrastructureBeanWithId(builder.getRawBeanDefinition(), AUDITING_ENTITY_LISTENER_CLASS_NAME, parser,
+ element);
- private BeanDefinition createLazyInitTargetSourceBeanDefinition(
- String auditorAwareRef) {
+ RootBeanDefinition def = new RootBeanDefinition();
+ def.setBeanClassName(AUDITING_BFPP_CLASS_NAME);
+ registerInfrastructureBeanWithId(def, AUDITING_BFPP_CLASS_NAME, parser, element);
- BeanDefinitionBuilder targetSourceBuilder =
- rootBeanDefinition(LazyInitTargetSource.class);
- targetSourceBuilder.addPropertyValue("targetBeanName", auditorAwareRef);
+ return null;
+ }
- BeanDefinitionBuilder builder =
- rootBeanDefinition(ProxyFactoryBean.class);
- builder.addPropertyValue("targetSource",
- targetSourceBuilder.getBeanDefinition());
+ private BeanDefinition createLazyInitTargetSourceBeanDefinition(String auditorAwareRef) {
- return builder.getBeanDefinition();
- }
+ BeanDefinitionBuilder targetSourceBuilder = rootBeanDefinition(LazyInitTargetSource.class);
+ targetSourceBuilder.addPropertyValue("targetBeanName", auditorAwareRef);
+ BeanDefinitionBuilder builder = rootBeanDefinition(ProxyFactoryBean.class);
+ builder.addPropertyValue("targetSource", targetSourceBuilder.getBeanDefinition());
- private void registerInfrastructureBeanWithId(AbstractBeanDefinition def,
- String id, ParserContext context, Element element) {
+ return builder.getBeanDefinition();
+ }
- def.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
- def.setSource(context.extractSource(element));
- context.registerBeanComponent(new BeanComponentDefinition(def, id));
- }
+ private void registerInfrastructureBeanWithId(AbstractBeanDefinition def, String id, ParserContext context,
+ Element element) {
- /**
- * Copied code of SpringConfiguredBeanDefinitionParser until this class gets
- * public.
- *
- * @see http://jira.springframework.org/browse/SPR-7340
- * @author Juergen Hoeller
- */
- private static class SpringConfiguredBeanDefinitionParser implements
- BeanDefinitionParser {
+ def.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
+ def.setSource(context.extractSource(element));
+ context.registerBeanComponent(new BeanComponentDefinition(def, id));
+ }
- /**
- * The bean name of the internally managed bean configurer aspect.
- */
- private static final String BEAN_CONFIGURER_ASPECT_BEAN_NAME =
- "org.springframework.context.config.internalBeanConfigurerAspect";
+ /**
+ * Copied code of SpringConfiguredBeanDefinitionParser until this class gets public.
+ *
+ * @see http://jira.springframework.org/browse/SPR-7340
+ * @author Juergen Hoeller
+ */
+ private static class SpringConfiguredBeanDefinitionParser implements BeanDefinitionParser {
- private static final String BEAN_CONFIGURER_ASPECT_CLASS_NAME =
- "org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect";
+ /**
+ * The bean name of the internally managed bean configurer aspect.
+ */
+ private static final String BEAN_CONFIGURER_ASPECT_BEAN_NAME = "org.springframework.context.config.internalBeanConfigurerAspect";
+ private static final String BEAN_CONFIGURER_ASPECT_CLASS_NAME = "org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect";
- public BeanDefinition parse(Element element, ParserContext parserContext) {
+ public BeanDefinition parse(Element element, ParserContext parserContext) {
- if (!parserContext.getRegistry().containsBeanDefinition(
- BEAN_CONFIGURER_ASPECT_BEAN_NAME)) {
- RootBeanDefinition def = new RootBeanDefinition();
- def.setBeanClassName(BEAN_CONFIGURER_ASPECT_CLASS_NAME);
- def.setFactoryMethodName("aspectOf");
+ if (!parserContext.getRegistry().containsBeanDefinition(BEAN_CONFIGURER_ASPECT_BEAN_NAME)) {
+ RootBeanDefinition def = new RootBeanDefinition();
+ def.setBeanClassName(BEAN_CONFIGURER_ASPECT_CLASS_NAME);
+ def.setFactoryMethodName("aspectOf");
- def.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
- def.setSource(parserContext.extractSource(element));
- parserContext
- .registerBeanComponent(new BeanComponentDefinition(def,
- BEAN_CONFIGURER_ASPECT_BEAN_NAME));
- }
- return null;
- }
- }
+ def.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
+ def.setSource(parserContext.extractSource(element));
+ parserContext.registerBeanComponent(new BeanComponentDefinition(def, BEAN_CONFIGURER_ASPECT_BEAN_NAME));
+ }
+ return null;
+ }
+ }
}
View
216 ...a/org/springframework/data/jpa/repository/config/JpaRepositoryConfigDefinitionParser.java
@@ -26,132 +26,106 @@
import org.springframework.util.StringUtils;
import org.w3c.dom.Element;
-
/**
- * Parser to create bean definitions for repositories namespace. Registers bean
- * definitions for repositories as well as
- * {@code PersistenceAnnotationBeanPostProcessor} and
- * {@code PersistenceExceptionTranslationPostProcessor} to transparently inject
- * entity manager factory instance and apply exception translation.
+ * Parser to create bean definitions for repositories namespace. Registers bean definitions for repositories as well as
+ * {@code PersistenceAnnotationBeanPostProcessor} and {@code PersistenceExceptionTranslationPostProcessor} to
+ * transparently inject entity manager factory instance and apply exception translation.
* <p>
- * The definition parser allows two ways of configuration. Either it looks up
- * the manually defined repository instances or scans the defined domain package
- * for candidates for repositories.
+ * The definition parser allows two ways of configuration. Either it looks up the manually defined repository instances
+ * or scans the defined domain package for candidates for repositories.
*
* @author Oliver Gierke
* @author Eberhard Wolff
* @author Gil Markham
*/
-class JpaRepositoryConfigDefinitionParser
- extends
- AbstractRepositoryConfigDefinitionParser<SimpleJpaRepositoryConfiguration, JpaRepositoryConfiguration> {
-
- private static final Class<?> PAB_POST_PROCESSOR =
- PersistenceAnnotationBeanPostProcessor.class;
- private static final Class<?> PET_POST_PROCESSOR =
- PersistenceExceptionTranslationPostProcessor.class;
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.springframework.data.repository.config.
- * AbstractRepositoryConfigDefinitionParser
- * #getGlobalRepositoryConfigInformation(org.w3c.dom.Element)
- */
- @Override
- protected SimpleJpaRepositoryConfiguration getGlobalRepositoryConfigInformation(
- Element element) {
-
- return new SimpleJpaRepositoryConfiguration(element);