formatted sources & added formatting file from spring-data-jpa
This commit is contained in:
291
eclipse-formatting.xml
Normal file
291
eclipse-formatting.xml
Normal file
@@ -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>
|
||||
@@ -53,7 +53,7 @@ public abstract class AbstractCassandraConfiguration {
|
||||
* @return must not be {@literal null}.
|
||||
*/
|
||||
protected abstract String getKeyspaceName();
|
||||
|
||||
|
||||
/**
|
||||
* Return the {@link Cluster} instance to connect to.
|
||||
*
|
||||
@@ -62,10 +62,10 @@ public abstract class AbstractCassandraConfiguration {
|
||||
*/
|
||||
@Bean
|
||||
public abstract Cluster cluster() throws Exception;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a {@link Session} to be used by the {@link Keyspace}. Will use the {@link Cluster} instance
|
||||
* configured in {@link #cluster()}.
|
||||
* Creates a {@link Session} to be used by the {@link Keyspace}. Will use the {@link Cluster} instance configured in
|
||||
* {@link #cluster()}.
|
||||
*
|
||||
* @see #cluster()
|
||||
* @see #Keyspace()
|
||||
@@ -77,12 +77,11 @@ public abstract class AbstractCassandraConfiguration {
|
||||
String keyspace = getKeyspaceName();
|
||||
if (StringUtils.hasText(keyspace)) {
|
||||
return cluster().connect(keyspace);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return cluster().connect();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a {@link Keyspace} to be used by the {@link CassandraTemplate}. Will use the {@link Session} instance
|
||||
* configured in {@link #session()} and {@link CassandraConverter} configured in {@link #converter()}.
|
||||
@@ -96,9 +95,10 @@ public abstract class AbstractCassandraConfiguration {
|
||||
public Keyspace keyspace() throws Exception {
|
||||
return new Keyspace(getKeyspaceName(), session(), converter());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the base package to scan for mapped {@link Table}s. Will return the package name of the configuration
|
||||
* class' (the concrete class, not this one here) by default. So if you have a {@code com.acme.AppConfig} extending
|
||||
* Return the base package to scan for mapped {@link Table}s. Will return the package name of the configuration class'
|
||||
* (the concrete class, not this one here) by default. So if you have a {@code com.acme.AppConfig} extending
|
||||
* {@link AbstractCassandraConfiguration} the base package will be considered {@code com.acme} unless the method is
|
||||
* overriden to implement alternate behaviour.
|
||||
*
|
||||
@@ -108,7 +108,7 @@ public abstract class AbstractCassandraConfiguration {
|
||||
protected String getMappingBasePackage() {
|
||||
return getClass().getPackage().getName();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a {@link CassandraTemplate}.
|
||||
*
|
||||
@@ -119,7 +119,7 @@ public abstract class AbstractCassandraConfiguration {
|
||||
public CassandraTemplate cassandraTemplate() throws Exception {
|
||||
return new CassandraTemplate(keyspace());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the {@link MappingContext} instance to map Entities to properties.
|
||||
*
|
||||
@@ -130,7 +130,7 @@ public abstract class AbstractCassandraConfiguration {
|
||||
public MappingContext<? extends CassandraPersistentEntity<?>, CassandraPersistentProperty> mappingContext() {
|
||||
return new CassandraMappingContext();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the {@link CassandraConverter} instance to convert Rows to Objects.
|
||||
*
|
||||
@@ -141,7 +141,7 @@ public abstract class AbstractCassandraConfiguration {
|
||||
public CassandraConverter converter() {
|
||||
return new MappingCassandraConverter(mappingContext());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Scans the mapping base package for classes annotated with {@link Table}.
|
||||
*
|
||||
@@ -168,5 +168,5 @@ public abstract class AbstractCassandraConfiguration {
|
||||
|
||||
return initialEntitySet;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.w3c.dom.Element;
|
||||
* @author Alex Shvid
|
||||
*/
|
||||
|
||||
public class CassandraClusterParser extends AbstractSimpleBeanDefinitionParser {
|
||||
public class CassandraClusterParser extends AbstractSimpleBeanDefinitionParser {
|
||||
|
||||
@Override
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
@@ -55,27 +55,26 @@ public class CassandraClusterParser extends AbstractSimpleBeanDefinitionParser
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext,
|
||||
BeanDefinitionBuilder builder) {
|
||||
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
|
||||
String contactPoints = element.getAttribute("contactPoints");
|
||||
if (StringUtils.hasText(contactPoints)) {
|
||||
builder.addPropertyValue("contactPoints", contactPoints);
|
||||
}
|
||||
|
||||
|
||||
String port = element.getAttribute("port");
|
||||
if (StringUtils.hasText(port)) {
|
||||
builder.addPropertyValue("port", port);
|
||||
}
|
||||
|
||||
|
||||
String compression = element.getAttribute("compression");
|
||||
if (StringUtils.hasText(compression)) {
|
||||
builder.addPropertyValue("compressionType", CompressionType.valueOf(compression));
|
||||
}
|
||||
|
||||
|
||||
postProcess(builder, element);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void postProcess(BeanDefinitionBuilder builder, Element element) {
|
||||
List<Element> subElements = DomUtils.getChildElements(element);
|
||||
@@ -86,17 +85,15 @@ public class CassandraClusterParser extends AbstractSimpleBeanDefinitionParser
|
||||
|
||||
if ("local-pooling-options".equals(name)) {
|
||||
builder.addPropertyValue("localPoolingOptions", parsePoolingOptions(subElement));
|
||||
}
|
||||
else if ("remote-pooling-options".equals(name)) {
|
||||
} else if ("remote-pooling-options".equals(name)) {
|
||||
builder.addPropertyValue("remotePoolingOptions", parsePoolingOptions(subElement));
|
||||
}
|
||||
else if ("socket-options".equals(name)) {
|
||||
} else if ("socket-options".equals(name)) {
|
||||
builder.addPropertyValue("socketOptions", parseSocketOptions(subElement));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private BeanDefinition parsePoolingOptions(Element element) {
|
||||
BeanDefinitionBuilder defBuilder = BeanDefinitionBuilder.genericBeanDefinition(PoolingOptionsConfig.class);
|
||||
ParsingUtils.setPropertyValue(defBuilder, element, "min-simultaneous-requests", "minSimultaneousRequests");
|
||||
@@ -104,8 +101,8 @@ public class CassandraClusterParser extends AbstractSimpleBeanDefinitionParser
|
||||
ParsingUtils.setPropertyValue(defBuilder, element, "core-connections", "coreConnections");
|
||||
ParsingUtils.setPropertyValue(defBuilder, element, "max-connections", "maxConnections");
|
||||
return defBuilder.getBeanDefinition();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private BeanDefinition parseSocketOptions(Element element) {
|
||||
BeanDefinitionBuilder defBuilder = BeanDefinitionBuilder.genericBeanDefinition(SocketOptionsConfig.class);
|
||||
ParsingUtils.setPropertyValue(defBuilder, element, "connect-timeout-mls", "connectTimeoutMls");
|
||||
@@ -116,6 +113,6 @@ public class CassandraClusterParser extends AbstractSimpleBeanDefinitionParser
|
||||
ParsingUtils.setPropertyValue(defBuilder, element, "receive-buffer-size", "receiveBufferSize");
|
||||
ParsingUtils.setPropertyValue(defBuilder, element, "send-buffer-size", "sendBufferSize");
|
||||
return defBuilder.getBeanDefinition();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,8 +36,7 @@ import org.w3c.dom.Element;
|
||||
* @author Alex Shvid
|
||||
*/
|
||||
|
||||
|
||||
public class CassandraKeyspaceParser extends AbstractSimpleBeanDefinitionParser {
|
||||
public class CassandraKeyspaceParser extends AbstractSimpleBeanDefinitionParser {
|
||||
|
||||
@Override
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
@@ -55,16 +54,15 @@ public class CassandraKeyspaceParser extends AbstractSimpleBeanDefinitionParser
|
||||
String id = super.resolveId(element, definition, parserContext);
|
||||
return StringUtils.hasText(id) ? id : BeanNames.CASSANDRA_KEYSPACE;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void doParse(Element element, ParserContext parserContext,
|
||||
BeanDefinitionBuilder builder) {
|
||||
|
||||
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
|
||||
|
||||
String name = element.getAttribute("name");
|
||||
if (StringUtils.hasText(name)) {
|
||||
builder.addPropertyValue("keyspace", name);
|
||||
}
|
||||
|
||||
|
||||
String clusterRef = element.getAttribute("cassandra-cluster-ref");
|
||||
if (!StringUtils.hasText(clusterRef)) {
|
||||
clusterRef = BeanNames.CASSANDRA_CLUSTER;
|
||||
@@ -78,7 +76,7 @@ public class CassandraKeyspaceParser extends AbstractSimpleBeanDefinitionParser
|
||||
|
||||
postProcess(builder, element);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void postProcess(BeanDefinitionBuilder builder, Element element) {
|
||||
List<Element> subElements = DomUtils.getChildElements(element);
|
||||
@@ -86,28 +84,28 @@ public class CassandraKeyspaceParser extends AbstractSimpleBeanDefinitionParser
|
||||
// parse nested elements
|
||||
for (Element subElement : subElements) {
|
||||
String name = subElement.getLocalName();
|
||||
|
||||
|
||||
if ("keyspace-attributes".equals(name)) {
|
||||
builder.addPropertyValue("keyspaceAttributes", parseKeyspaceAttributes(subElement));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private BeanDefinition parseKeyspaceAttributes(Element element) {
|
||||
BeanDefinitionBuilder defBuilder = BeanDefinitionBuilder.genericBeanDefinition(KeyspaceAttributes.class);
|
||||
ParsingUtils.setPropertyValue(defBuilder, element, "auto", "auto");
|
||||
ParsingUtils.setPropertyValue(defBuilder, element, "replication-strategy", "replicationStrategy");
|
||||
ParsingUtils.setPropertyValue(defBuilder, element, "replication-factor", "replicationFactor");
|
||||
ParsingUtils.setPropertyValue(defBuilder, element, "durable-writes", "durableWrites");
|
||||
|
||||
|
||||
List<Element> subElements = DomUtils.getChildElements(element);
|
||||
ManagedList<Object> tables = new ManagedList<Object>(subElements.size());
|
||||
|
||||
|
||||
// parse nested elements
|
||||
for (Element subElement : subElements) {
|
||||
String name = subElement.getLocalName();
|
||||
|
||||
|
||||
if ("table".equals(name)) {
|
||||
tables.add(parseTable(subElement));
|
||||
}
|
||||
@@ -115,10 +113,10 @@ public class CassandraKeyspaceParser extends AbstractSimpleBeanDefinitionParser
|
||||
if (!tables.isEmpty()) {
|
||||
defBuilder.addPropertyValue("tables", tables);
|
||||
}
|
||||
|
||||
|
||||
return defBuilder.getBeanDefinition();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private BeanDefinition parseTable(Element element) {
|
||||
BeanDefinitionBuilder defBuilder = BeanDefinitionBuilder.genericBeanDefinition(TableAttributes.class);
|
||||
ParsingUtils.setPropertyValue(defBuilder, element, "entity", "entity");
|
||||
|
||||
@@ -26,10 +26,10 @@ import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
|
||||
public class CassandraNamespaceHandler extends NamespaceHandlerSupport {
|
||||
|
||||
public void init() {
|
||||
|
||||
|
||||
registerBeanDefinitionParser("cluster", new CassandraClusterParser());
|
||||
registerBeanDefinitionParser("keyspace", new CassandraKeyspaceParser());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -18,9 +18,8 @@ package org.springframework.data.cassandra.config;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Keyspace attributes are used for manipulation around keyspace at the startup.
|
||||
* Auto property defines the way how to do this. Other attributes used to
|
||||
* ensure or update keyspace settings.
|
||||
* Keyspace attributes are used for manipulation around keyspace at the startup. Auto property defines the way how to do
|
||||
* this. Other attributes used to ensure or update keyspace settings.
|
||||
*
|
||||
* @author Alex Shvid
|
||||
*/
|
||||
@@ -29,34 +28,34 @@ public class KeyspaceAttributes {
|
||||
public static final String DEFAULT_REPLICATION_STRATEGY = "SimpleStrategy";
|
||||
public static final int DEFAULT_REPLICATION_FACTOR = 1;
|
||||
public static final boolean DEFAULT_DURABLE_WRITES = true;
|
||||
|
||||
|
||||
/*
|
||||
* auto possible values:
|
||||
* validate: validate the keyspace, makes no changes.
|
||||
* update: update the keyspace.
|
||||
* create: creates the keyspace, destroying previous data.
|
||||
* create-drop: drop the keyspace at the end of the session.
|
||||
* update: update the keyspace.
|
||||
* create: creates the keyspace, destroying previous data.
|
||||
* create-drop: drop the keyspace at the end of the session.
|
||||
*/
|
||||
public static final String AUTO_VALIDATE = "validate";
|
||||
public static final String AUTO_UPDATE = "update";
|
||||
public static final String AUTO_CREATE = "create";
|
||||
public static final String AUTO_CREATE_DROP = "create-drop";
|
||||
|
||||
|
||||
private String auto = AUTO_VALIDATE;
|
||||
private String replicationStrategy = DEFAULT_REPLICATION_STRATEGY;
|
||||
private int replicationFactor = DEFAULT_REPLICATION_FACTOR;
|
||||
private boolean durableWrites = DEFAULT_DURABLE_WRITES;
|
||||
|
||||
private Collection<TableAttributes> tables;
|
||||
|
||||
|
||||
public String getAuto() {
|
||||
return auto;
|
||||
}
|
||||
|
||||
|
||||
public void setAuto(String auto) {
|
||||
this.auto = auto;
|
||||
}
|
||||
|
||||
|
||||
public boolean isValidate() {
|
||||
return AUTO_VALIDATE.equals(auto);
|
||||
}
|
||||
@@ -76,15 +75,15 @@ public class KeyspaceAttributes {
|
||||
public String getReplicationStrategy() {
|
||||
return replicationStrategy;
|
||||
}
|
||||
|
||||
|
||||
public void setReplicationStrategy(String replicationStrategy) {
|
||||
this.replicationStrategy = replicationStrategy;
|
||||
}
|
||||
|
||||
|
||||
public int getReplicationFactor() {
|
||||
return replicationFactor;
|
||||
}
|
||||
|
||||
|
||||
public void setReplicationFactor(int replicationFactor) {
|
||||
this.replicationFactor = replicationFactor;
|
||||
}
|
||||
@@ -104,5 +103,5 @@ public class KeyspaceAttributes {
|
||||
public void setTables(Collection<TableAttributes> tables) {
|
||||
this.tables = tables;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class TableAttributes {
|
||||
|
||||
private String entity;
|
||||
private String name;
|
||||
|
||||
|
||||
public String getEntity() {
|
||||
return entity;
|
||||
}
|
||||
@@ -32,7 +32,7 @@ public class TableAttributes {
|
||||
public void setEntity(String entity) {
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@@ -45,5 +45,5 @@ public class TableAttributes {
|
||||
public String toString() {
|
||||
return "TableAttributes [entity=" + entity + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -22,16 +22,16 @@ import org.springframework.core.convert.support.GenericConversionService;
|
||||
import org.springframework.data.convert.EntityInstantiators;
|
||||
|
||||
/**
|
||||
* Base class for {@link CassandraConverter} implementations. Sets up a {@link GenericConversionService} and populates basic
|
||||
* converters.
|
||||
* Base class for {@link CassandraConverter} implementations. Sets up a {@link GenericConversionService} and populates
|
||||
* basic converters.
|
||||
*
|
||||
* @author Alex Shvid
|
||||
*/
|
||||
public abstract class AbstractCassandraConverter implements CassandraConverter, InitializingBean {
|
||||
public abstract class AbstractCassandraConverter implements CassandraConverter, InitializingBean {
|
||||
|
||||
protected final GenericConversionService conversionService;
|
||||
protected EntityInstantiators instantiators = new EntityInstantiators();
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new {@link AbstractMongoConverter} using the given {@link GenericConversionService}.
|
||||
*
|
||||
@@ -40,7 +40,7 @@ public abstract class AbstractCassandraConverter implements CassandraConverter,
|
||||
public AbstractCassandraConverter(GenericConversionService conversionService) {
|
||||
this.conversionService = conversionService == null ? new DefaultConversionService() : conversionService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Registers {@link EntityInstantiators} to customize entity instantiation.
|
||||
*
|
||||
@@ -49,7 +49,7 @@ public abstract class AbstractCassandraConverter implements CassandraConverter,
|
||||
public void setInstantiators(EntityInstantiators instantiators) {
|
||||
this.instantiators = instantiators == null ? new EntityInstantiators() : instantiators;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.mongodb.core.core.convert.MongoConverter#getConversionService()
|
||||
@@ -57,11 +57,11 @@ public abstract class AbstractCassandraConverter implements CassandraConverter,
|
||||
public ConversionService getConversionService() {
|
||||
return conversionService;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
|
||||
*/
|
||||
public void afterPropertiesSet() {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.datastax.driver.core.Row;
|
||||
*
|
||||
* @author Alex Shvid
|
||||
*/
|
||||
public interface CassandraConverter extends EntityConverter<CassandraPersistentEntity<?>, CassandraPersistentProperty, Object, Row> {
|
||||
public interface CassandraConverter extends
|
||||
EntityConverter<CassandraPersistentEntity<?>, CassandraPersistentProperty, Object, Row> {
|
||||
|
||||
}
|
||||
|
||||
@@ -35,14 +35,15 @@ import com.datastax.driver.core.Row;
|
||||
* @author Alex Shvid
|
||||
*/
|
||||
public class CassandraPropertyValueProvider implements PropertyValueProvider<CassandraPersistentProperty> {
|
||||
|
||||
|
||||
private static Logger log = LoggerFactory.getLogger(CassandraPropertyValueProvider.class);
|
||||
|
||||
private final Row source;
|
||||
private final SpELExpressionEvaluator evaluator;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new {@link CassandraPropertyValueProvider} with the given {@link Row} and {@link DefaultSpELExpressionEvaluator}.
|
||||
* Creates a new {@link CassandraPropertyValueProvider} with the given {@link Row} and
|
||||
* {@link DefaultSpELExpressionEvaluator}.
|
||||
*
|
||||
* @param source must not be {@literal null}.
|
||||
* @param evaluator must not be {@literal null}.
|
||||
@@ -54,41 +55,41 @@ public class CassandraPropertyValueProvider implements PropertyValueProvider<Cas
|
||||
this.source = source;
|
||||
this.evaluator = evaluator;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.convert.PropertyValueProvider#getPropertyValue(org.springframework.data.mapping.PersistentProperty)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getPropertyValue(CassandraPersistentProperty property) {
|
||||
|
||||
|
||||
String expression = property.getSpelExpression();
|
||||
if (expression != null) {
|
||||
return evaluator.evaluate(expression);
|
||||
}
|
||||
|
||||
|
||||
String columnName = property.getColumnName();
|
||||
if (source.isNull(property.getColumnName())) {
|
||||
return null;
|
||||
}
|
||||
DataType columnType = source.getColumnDefinitions().getType(columnName);
|
||||
|
||||
|
||||
log.info(columnType.getName().name());
|
||||
|
||||
|
||||
/*
|
||||
* Dave Webb - Added handler for text since getBytes was throwing
|
||||
* InvalidTypeException when using getBytes on a text column.
|
||||
*/
|
||||
//TODO Might need to qualify all DataTypes as we encounter them.
|
||||
// TODO Might need to qualify all DataTypes as we encounter them.
|
||||
if (columnType.equals(DataType.text())) {
|
||||
return (T) source.getString(columnName);
|
||||
}
|
||||
if (columnType.equals(DataType.cint())) {
|
||||
return (T) new Integer(source.getInt(columnName));
|
||||
}
|
||||
|
||||
|
||||
ByteBuffer bytes = source.getBytes(columnName);
|
||||
return (T) columnType.deserialize(bytes);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -46,36 +46,38 @@ import com.datastax.driver.core.Row;
|
||||
public class MappingCassandraConverter extends AbstractCassandraConverter implements ApplicationContextAware {
|
||||
|
||||
protected static final Logger log = LoggerFactory.getLogger(MappingCassandraConverter.class);
|
||||
|
||||
|
||||
protected final MappingContext<? extends CassandraPersistentEntity<?>, CassandraPersistentProperty> mappingContext;
|
||||
protected ApplicationContext applicationContext;
|
||||
private SpELContext spELContext;
|
||||
private boolean useFieldAccessOnly = true;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new {@link MappingCassandraConverter} given the new {@link MappingContext}.
|
||||
*
|
||||
* @param mappingContext must not be {@literal null}.
|
||||
*/
|
||||
public MappingCassandraConverter(MappingContext<? extends CassandraPersistentEntity<?>, CassandraPersistentProperty> mappingContext) {
|
||||
public MappingCassandraConverter(
|
||||
MappingContext<? extends CassandraPersistentEntity<?>, CassandraPersistentProperty> mappingContext) {
|
||||
super(new DefaultConversionService());
|
||||
this.mappingContext = mappingContext;
|
||||
this.spELContext = new SpELContext(RowReaderPropertyAccessor.INSTANCE);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <R> R read(Class<R> clazz, Row row) {
|
||||
|
||||
|
||||
TypeInformation<? extends R> type = ClassTypeInformation.from(clazz);
|
||||
//TypeInformation<? extends R> typeToUse = typeMapper.readType(row, type);
|
||||
// TypeInformation<? extends R> typeToUse = typeMapper.readType(row, type);
|
||||
TypeInformation<? extends R> typeToUse = type;
|
||||
Class<? extends R> rawType = typeToUse.getType();
|
||||
|
||||
if (Row.class.isAssignableFrom(rawType)) {
|
||||
return (R) row;
|
||||
}
|
||||
|
||||
CassandraPersistentEntity<R> persistentEntity = (CassandraPersistentEntity<R>) mappingContext.getPersistentEntity(typeToUse);
|
||||
|
||||
CassandraPersistentEntity<R> persistentEntity = (CassandraPersistentEntity<R>) mappingContext
|
||||
.getPersistentEntity(typeToUse);
|
||||
if (persistentEntity == null) {
|
||||
throw new MappingException("No mapping metadata found for " + rawType.getName());
|
||||
}
|
||||
@@ -99,15 +101,16 @@ public class MappingCassandraConverter extends AbstractCassandraConverter implem
|
||||
this.applicationContext = applicationContext;
|
||||
this.spELContext = new SpELContext(this.spELContext, applicationContext);
|
||||
}
|
||||
|
||||
|
||||
private <S extends Object> S read(final CassandraPersistentEntity<S> entity, final Row row) {
|
||||
|
||||
final DefaultSpELExpressionEvaluator evaluator = new DefaultSpELExpressionEvaluator(row, spELContext);
|
||||
|
||||
final PropertyValueProvider<CassandraPersistentProperty> propertyProvider = new CassandraPropertyValueProvider(row, evaluator);
|
||||
final PropertyValueProvider<CassandraPersistentProperty> propertyProvider = new CassandraPropertyValueProvider(row,
|
||||
evaluator);
|
||||
PersistentEntityParameterValueProvider<CassandraPersistentProperty> parameterProvider = new PersistentEntityParameterValueProvider<CassandraPersistentProperty>(
|
||||
entity, propertyProvider, null);
|
||||
|
||||
|
||||
EntityInstantiator instantiator = instantiators.getInstantiatorFor(entity);
|
||||
S instance = instantiator.createInstance(entity, parameterProvider);
|
||||
|
||||
@@ -129,7 +132,7 @@ public class MappingCassandraConverter extends AbstractCassandraConverter implem
|
||||
wrapper.setProperty(prop, obj, useFieldAccessOnly);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -142,16 +145,14 @@ public class MappingCassandraConverter extends AbstractCassandraConverter implem
|
||||
*/
|
||||
@Override
|
||||
public void write(Object source, Row sink) {
|
||||
|
||||
|
||||
/*
|
||||
* There is no concept of passing a Row into Cassandra for Writing.
|
||||
* This must be done with Query
|
||||
*
|
||||
* See the CQLUtils.
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -41,34 +41,34 @@ import com.datastax.driver.core.policies.RetryPolicy;
|
||||
* @author Alex Shvid
|
||||
*/
|
||||
|
||||
public class CassandraClusterFactoryBean implements FactoryBean<Cluster>,
|
||||
InitializingBean, DisposableBean, PersistenceExceptionTranslator {
|
||||
public class CassandraClusterFactoryBean implements FactoryBean<Cluster>, InitializingBean, DisposableBean,
|
||||
PersistenceExceptionTranslator {
|
||||
|
||||
private static final int DEFAULT_PORT = 9042;
|
||||
|
||||
|
||||
private Cluster cluster;
|
||||
|
||||
|
||||
private String contactPoints;
|
||||
private int port = DEFAULT_PORT;
|
||||
private CompressionType compressionType;
|
||||
|
||||
|
||||
private PoolingOptionsConfig localPoolingOptions;
|
||||
private PoolingOptionsConfig remotePoolingOptions;
|
||||
private SocketOptionsConfig socketOptions;
|
||||
|
||||
|
||||
private AuthProvider authProvider;
|
||||
private LoadBalancingPolicy loadBalancingPolicy;
|
||||
private ReconnectionPolicy reconnectionPolicy;
|
||||
private RetryPolicy retryPolicy;
|
||||
|
||||
|
||||
private boolean metricsEnabled = true;
|
||||
|
||||
|
||||
private final PersistenceExceptionTranslator exceptionTranslator = new CassandraExceptionTranslator();
|
||||
|
||||
public Cluster getObject() throws Exception {
|
||||
return cluster;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.beans.factory.FactoryBean#getObjectType()
|
||||
@@ -84,7 +84,7 @@ public class CassandraClusterFactoryBean implements FactoryBean<Cluster>,
|
||||
public boolean isSingleton() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.dao.support.PersistenceExceptionTranslator#translateExceptionIfPossible(java.lang.RuntimeException)
|
||||
@@ -92,22 +92,21 @@ public class CassandraClusterFactoryBean implements FactoryBean<Cluster>,
|
||||
public DataAccessException translateExceptionIfPossible(RuntimeException ex) {
|
||||
return exceptionTranslator.translateExceptionIfPossible(ex);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
|
||||
*/
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
|
||||
|
||||
if (!StringUtils.hasText(contactPoints)) {
|
||||
throw new IllegalArgumentException(
|
||||
"at least one server is required");
|
||||
throw new IllegalArgumentException("at least one server is required");
|
||||
}
|
||||
|
||||
|
||||
Cluster.Builder builder = Cluster.builder();
|
||||
|
||||
builder.addContactPoints(StringUtils.commaDelimitedListToStringArray(contactPoints)).withPort(port);
|
||||
|
||||
|
||||
if (compressionType != null) {
|
||||
builder.withCompression(convertCompressionType(compressionType));
|
||||
}
|
||||
@@ -123,33 +122,33 @@ public class CassandraClusterFactoryBean implements FactoryBean<Cluster>,
|
||||
if (socketOptions != null) {
|
||||
builder.withSocketOptions(configSocketOptions(socketOptions));
|
||||
}
|
||||
|
||||
|
||||
if (authProvider != null) {
|
||||
builder.withAuthProvider(authProvider);
|
||||
}
|
||||
|
||||
|
||||
if (loadBalancingPolicy != null) {
|
||||
builder.withLoadBalancingPolicy(loadBalancingPolicy);
|
||||
}
|
||||
|
||||
|
||||
if (reconnectionPolicy != null) {
|
||||
builder.withReconnectionPolicy(reconnectionPolicy);
|
||||
}
|
||||
|
||||
|
||||
if (retryPolicy != null) {
|
||||
builder.withRetryPolicy(retryPolicy);
|
||||
}
|
||||
|
||||
|
||||
if (!metricsEnabled) {
|
||||
builder.withoutMetrics();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Cluster cluster = builder.build();
|
||||
|
||||
|
||||
// initialize property
|
||||
this.cluster = cluster;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.beans.factory.DisposableBean#destroy()
|
||||
@@ -169,7 +168,7 @@ public class CassandraClusterFactoryBean implements FactoryBean<Cluster>,
|
||||
public void setCompressionType(CompressionType compressionType) {
|
||||
this.compressionType = compressionType;
|
||||
}
|
||||
|
||||
|
||||
public void setLocalPoolingOptions(PoolingOptionsConfig localPoolingOptions) {
|
||||
this.localPoolingOptions = localPoolingOptions;
|
||||
}
|
||||
@@ -185,7 +184,7 @@ public class CassandraClusterFactoryBean implements FactoryBean<Cluster>,
|
||||
public void setAuthProvider(AuthProvider authProvider) {
|
||||
this.authProvider = authProvider;
|
||||
}
|
||||
|
||||
|
||||
public void setLoadBalancingPolicy(LoadBalancingPolicy loadBalancingPolicy) {
|
||||
this.loadBalancingPolicy = loadBalancingPolicy;
|
||||
}
|
||||
@@ -203,23 +202,25 @@ public class CassandraClusterFactoryBean implements FactoryBean<Cluster>,
|
||||
}
|
||||
|
||||
private static Compression convertCompressionType(CompressionType type) {
|
||||
switch(type) {
|
||||
switch (type) {
|
||||
case NONE:
|
||||
return Compression.NONE;
|
||||
return Compression.NONE;
|
||||
case SNAPPY:
|
||||
return Compression.SNAPPY;
|
||||
}
|
||||
throw new IllegalArgumentException("unknown compression type " + type);
|
||||
}
|
||||
|
||||
|
||||
private static PoolingOptions configPoolingOptions(HostDistance hostDistance, PoolingOptionsConfig config) {
|
||||
PoolingOptions poolingOptions = new PoolingOptions();
|
||||
|
||||
if (config.getMinSimultaneousRequests() != null) {
|
||||
poolingOptions.setMinSimultaneousRequestsPerConnectionThreshold(hostDistance, config.getMinSimultaneousRequests());
|
||||
poolingOptions
|
||||
.setMinSimultaneousRequestsPerConnectionThreshold(hostDistance, config.getMinSimultaneousRequests());
|
||||
}
|
||||
if (config.getMaxSimultaneousRequests() != null) {
|
||||
poolingOptions.setMaxSimultaneousRequestsPerConnectionThreshold(hostDistance, config.getMaxSimultaneousRequests());
|
||||
poolingOptions
|
||||
.setMaxSimultaneousRequestsPerConnectionThreshold(hostDistance, config.getMaxSimultaneousRequests());
|
||||
}
|
||||
if (config.getCoreConnections() != null) {
|
||||
poolingOptions.setCoreConnectionsPerHost(hostDistance, config.getCoreConnections());
|
||||
@@ -227,13 +228,13 @@ public class CassandraClusterFactoryBean implements FactoryBean<Cluster>,
|
||||
if (config.getMaxConnections() != null) {
|
||||
poolingOptions.setMaxConnectionsPerHost(hostDistance, config.getMaxConnections());
|
||||
}
|
||||
|
||||
|
||||
return poolingOptions;
|
||||
}
|
||||
|
||||
|
||||
private static SocketOptions configSocketOptions(SocketOptionsConfig config) {
|
||||
SocketOptions socketOptions = new SocketOptions();
|
||||
|
||||
|
||||
if (config.getConnectTimeoutMls() != null) {
|
||||
socketOptions.setConnectTimeoutMillis(config.getConnectTimeoutMls());
|
||||
}
|
||||
@@ -255,7 +256,7 @@ public class CassandraClusterFactoryBean implements FactoryBean<Cluster>,
|
||||
if (config.getSendBufferSize() != null) {
|
||||
socketOptions.setSendBufferSize(config.getSendBufferSize());
|
||||
}
|
||||
|
||||
|
||||
return socketOptions;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,18 +52,15 @@ import com.datastax.driver.core.exceptions.UnavailableException;
|
||||
import com.datastax.driver.core.exceptions.WriteTimeoutException;
|
||||
|
||||
/**
|
||||
* Simple {@link PersistenceExceptionTranslator} for Cassandra. Convert the
|
||||
* given runtime exception to an appropriate exception from the
|
||||
* {@code org.springframework.dao} hierarchy. Return {@literal null} if no
|
||||
* translation is appropriate: any other exception may have resulted from user
|
||||
* code, and should not be translated.
|
||||
* Simple {@link PersistenceExceptionTranslator} for Cassandra. Convert the given runtime exception to an appropriate
|
||||
* exception from the {@code org.springframework.dao} hierarchy. Return {@literal null} if no translation is
|
||||
* appropriate: any other exception may have resulted from user code, and should not be translated.
|
||||
*
|
||||
* @author Alex Shvid
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
|
||||
public class CassandraExceptionTranslator implements
|
||||
PersistenceExceptionTranslator {
|
||||
public class CassandraExceptionTranslator implements PersistenceExceptionTranslator {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
@@ -81,8 +78,7 @@ public class CassandraExceptionTranslator implements
|
||||
// superclass would match before the subclass!
|
||||
|
||||
if (x instanceof AuthenticationException) {
|
||||
return new CassandraAuthenticationException(
|
||||
((AuthenticationException) x).getHost(), x.getMessage(), x);
|
||||
return new CassandraAuthenticationException(((AuthenticationException) x).getHost(), x.getMessage(), x);
|
||||
}
|
||||
if (x instanceof DriverInternalError) {
|
||||
return new CassandraInternalException(x.getMessage(), x);
|
||||
@@ -91,40 +87,31 @@ public class CassandraExceptionTranslator implements
|
||||
return new CassandraTypeMismatchException(x.getMessage(), x);
|
||||
}
|
||||
if (x instanceof NoHostAvailableException) {
|
||||
return new CassandraConnectionFailureException(
|
||||
((NoHostAvailableException) x).getErrors(), x.getMessage(),
|
||||
x);
|
||||
return new CassandraConnectionFailureException(((NoHostAvailableException) x).getErrors(), x.getMessage(), x);
|
||||
}
|
||||
if (x instanceof ReadTimeoutException) {
|
||||
return new CassandraReadTimeoutException(
|
||||
((ReadTimeoutException) x).wasDataRetrieved(),
|
||||
x.getMessage(), x);
|
||||
return new CassandraReadTimeoutException(((ReadTimeoutException) x).wasDataRetrieved(), x.getMessage(), x);
|
||||
}
|
||||
if (x instanceof WriteTimeoutException) {
|
||||
WriteType writeType = ((WriteTimeoutException) x).getWriteType();
|
||||
return new CassandraWriteTimeoutException(writeType == null ? null
|
||||
: writeType.name(), x.getMessage(), x);
|
||||
return new CassandraWriteTimeoutException(writeType == null ? null : writeType.name(), x.getMessage(), x);
|
||||
}
|
||||
if (x instanceof TruncateException) {
|
||||
return new CassandraTruncateException(x.getMessage(), x);
|
||||
}
|
||||
if (x instanceof UnavailableException) {
|
||||
UnavailableException ux = (UnavailableException) x;
|
||||
return new CassandraInsufficientReplicasAvailableException(
|
||||
ux.getRequiredReplicas(), ux.getAliveReplicas(),
|
||||
return new CassandraInsufficientReplicasAvailableException(ux.getRequiredReplicas(), ux.getAliveReplicas(),
|
||||
x.getMessage(), x);
|
||||
}
|
||||
if (x instanceof AlreadyExistsException) {
|
||||
AlreadyExistsException aex = (AlreadyExistsException) x;
|
||||
|
||||
return aex.wasTableCreation() ? new CassandraTableExistsException(
|
||||
aex.getTable(), x.getMessage(), x)
|
||||
: new CassandraKeyspaceExistsException(aex.getKeyspace(),
|
||||
x.getMessage(), x);
|
||||
return aex.wasTableCreation() ? new CassandraTableExistsException(aex.getTable(), x.getMessage(), x)
|
||||
: new CassandraKeyspaceExistsException(aex.getKeyspace(), x.getMessage(), x);
|
||||
}
|
||||
if (x instanceof InvalidConfigurationInQueryException) {
|
||||
return new CassandraInvalidConfigurationInQueryException(
|
||||
x.getMessage(), x);
|
||||
return new CassandraInvalidConfigurationInQueryException(x.getMessage(), x);
|
||||
}
|
||||
if (x instanceof InvalidQueryException) {
|
||||
return new CassandraInvalidQueryException(x.getMessage(), x);
|
||||
|
||||
@@ -25,10 +25,10 @@ import com.datastax.driver.core.DataType;
|
||||
* @author Alex Shvid
|
||||
*/
|
||||
public class CassandraValue {
|
||||
|
||||
|
||||
private final ByteBuffer value;
|
||||
private final DataType type;
|
||||
|
||||
|
||||
public CassandraValue(ByteBuffer value, DataType type) {
|
||||
this.value = value;
|
||||
this.type = type;
|
||||
@@ -41,5 +41,5 @@ public class CassandraValue {
|
||||
public DataType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.springframework.data.cassandra.convert.CassandraConverter;
|
||||
import com.datastax.driver.core.Session;
|
||||
|
||||
/**
|
||||
* Simple Cassandra Keyspace object
|
||||
* Simple Cassandra Keyspace object
|
||||
*
|
||||
* @author Alex Shvid
|
||||
*/
|
||||
@@ -29,7 +29,7 @@ public class Keyspace {
|
||||
private final String keyspace;
|
||||
private final Session session;
|
||||
private final CassandraConverter cassandraConverter;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor used for a basic keyspace configuration
|
||||
*
|
||||
@@ -42,7 +42,7 @@ public class Keyspace {
|
||||
this.session = session;
|
||||
this.cassandraConverter = cassandraConverter;
|
||||
}
|
||||
|
||||
|
||||
public String getKeyspace() {
|
||||
return keyspace;
|
||||
}
|
||||
|
||||
@@ -21,12 +21,12 @@ import com.datastax.driver.core.Host;
|
||||
|
||||
/**
|
||||
* @author David Webb
|
||||
*
|
||||
*
|
||||
*/
|
||||
public final class RingMember implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1345346346L;
|
||||
|
||||
|
||||
/*
|
||||
* Ring attributes
|
||||
*/
|
||||
@@ -34,8 +34,9 @@ public final class RingMember implements Serializable {
|
||||
public final String address;
|
||||
public final String DC;
|
||||
public final String rack;
|
||||
//public final String status;
|
||||
//public final String state;
|
||||
|
||||
// public final String status;
|
||||
// public final String state;
|
||||
|
||||
public RingMember(Host h) {
|
||||
this.hostName = h.getAddress().getHostName();
|
||||
|
||||
@@ -25,15 +25,13 @@ import org.springframework.dao.PermissionDeniedDataAccessException;
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
public class CassandraAuthenticationException extends
|
||||
PermissionDeniedDataAccessException {
|
||||
public class CassandraAuthenticationException extends PermissionDeniedDataAccessException {
|
||||
|
||||
private static final long serialVersionUID = 8556304586797273927L;
|
||||
|
||||
private InetAddress host;
|
||||
|
||||
public CassandraAuthenticationException(InetAddress host, String msg,
|
||||
Throwable cause) {
|
||||
public CassandraAuthenticationException(InetAddress host, String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
@@ -28,15 +28,13 @@ import org.springframework.dao.DataAccessResourceFailureException;
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
public class CassandraConnectionFailureException extends
|
||||
DataAccessResourceFailureException {
|
||||
public class CassandraConnectionFailureException extends DataAccessResourceFailureException {
|
||||
|
||||
private static final long serialVersionUID = 6299912054261646552L;
|
||||
|
||||
private final Map<InetAddress, String> messagesByHost = new HashMap<InetAddress, String>();
|
||||
|
||||
public CassandraConnectionFailureException(
|
||||
Map<InetAddress, String> messagesByHost, String msg, Throwable cause) {
|
||||
public CassandraConnectionFailureException(Map<InetAddress, String> messagesByHost, String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
this.messagesByHost.putAll(messagesByHost);
|
||||
}
|
||||
|
||||
@@ -19,13 +19,11 @@ package org.springframework.data.cassandra.core.exceptions;
|
||||
import org.springframework.dao.TransientDataAccessException;
|
||||
|
||||
/**
|
||||
* Spring data access exception for Cassandra when insufficient replicas are
|
||||
* available for a given consistency level.
|
||||
* Spring data access exception for Cassandra when insufficient replicas are available for a given consistency level.
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
public class CassandraInsufficientReplicasAvailableException extends
|
||||
TransientDataAccessException {
|
||||
public class CassandraInsufficientReplicasAvailableException extends TransientDataAccessException {
|
||||
|
||||
private static final long serialVersionUID = 6415130674604814905L;
|
||||
|
||||
@@ -36,8 +34,8 @@ public class CassandraInsufficientReplicasAvailableException extends
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public CassandraInsufficientReplicasAvailableException(int numberRequired,
|
||||
int numberAlive, String msg, Throwable cause) {
|
||||
public CassandraInsufficientReplicasAvailableException(int numberRequired, int numberAlive, String msg,
|
||||
Throwable cause) {
|
||||
super(msg, cause);
|
||||
this.numberRequired = numberRequired;
|
||||
this.numberAlive = numberAlive;
|
||||
|
||||
@@ -19,13 +19,12 @@ package org.springframework.data.cassandra.core.exceptions;
|
||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
|
||||
/**
|
||||
* Spring data access exception for a Cassandra query that is syntactically
|
||||
* correct but has an invalid configuration clause.
|
||||
* Spring data access exception for a Cassandra query that is syntactically correct but has an invalid configuration
|
||||
* clause.
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
public class CassandraInvalidConfigurationInQueryException extends
|
||||
InvalidDataAccessApiUsageException {
|
||||
public class CassandraInvalidConfigurationInQueryException extends InvalidDataAccessApiUsageException {
|
||||
|
||||
private static final long serialVersionUID = 4594321191806182918L;
|
||||
|
||||
@@ -33,8 +32,7 @@ public class CassandraInvalidConfigurationInQueryException extends
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public CassandraInvalidConfigurationInQueryException(String msg,
|
||||
Throwable cause) {
|
||||
public CassandraInvalidConfigurationInQueryException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,13 +19,11 @@ package org.springframework.data.cassandra.core.exceptions;
|
||||
import org.springframework.dao.InvalidDataAccessApiUsageException;
|
||||
|
||||
/**
|
||||
* Spring data access exception for a Cassandra query that's syntactically
|
||||
* correct but invalid.
|
||||
* Spring data access exception for a Cassandra query that's syntactically correct but invalid.
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
public class CassandraInvalidQueryException extends
|
||||
InvalidDataAccessApiUsageException {
|
||||
public class CassandraInvalidQueryException extends InvalidDataAccessApiUsageException {
|
||||
|
||||
private static final long serialVersionUID = 4594321191806182918L;
|
||||
|
||||
|
||||
@@ -17,18 +17,15 @@
|
||||
package org.springframework.data.cassandra.core.exceptions;
|
||||
|
||||
/**
|
||||
* Spring data access exception for Cassandra when a keyspace being created
|
||||
* already exists.
|
||||
* Spring data access exception for Cassandra when a keyspace being created already exists.
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
public class CassandraKeyspaceExistsException extends
|
||||
CassandraSchemaElementExistsException {
|
||||
public class CassandraKeyspaceExistsException extends CassandraSchemaElementExistsException {
|
||||
|
||||
private static final long serialVersionUID = 6032967419751410352L;
|
||||
|
||||
public CassandraKeyspaceExistsException(String keyspaceName, String msg,
|
||||
Throwable cause) {
|
||||
public CassandraKeyspaceExistsException(String keyspaceName, String msg, Throwable cause) {
|
||||
super(keyspaceName, ElementType.KEYSPACE, msg, cause);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,8 +29,7 @@ public class CassandraReadTimeoutException extends QueryTimeoutException {
|
||||
|
||||
private boolean wasDataReceived;
|
||||
|
||||
public CassandraReadTimeoutException(boolean wasDataReceived, String msg,
|
||||
Throwable cause) {
|
||||
public CassandraReadTimeoutException(boolean wasDataReceived, String msg, Throwable cause) {
|
||||
super(msg);
|
||||
this.wasDataReceived = wasDataReceived;
|
||||
}
|
||||
|
||||
@@ -19,13 +19,11 @@ package org.springframework.data.cassandra.core.exceptions;
|
||||
import org.springframework.dao.NonTransientDataAccessException;
|
||||
|
||||
/**
|
||||
* Spring data access exception for when Cassandra schema element being created
|
||||
* already exists.
|
||||
* Spring data access exception for when Cassandra schema element being created already exists.
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
public class CassandraSchemaElementExistsException extends
|
||||
NonTransientDataAccessException {
|
||||
public class CassandraSchemaElementExistsException extends NonTransientDataAccessException {
|
||||
|
||||
private static final long serialVersionUID = 7798361273692300162L;
|
||||
|
||||
@@ -36,8 +34,7 @@ public class CassandraSchemaElementExistsException extends
|
||||
private String elementName;
|
||||
private ElementType elementType;
|
||||
|
||||
public CassandraSchemaElementExistsException(String elementName,
|
||||
ElementType elementType, String msg, Throwable cause) {
|
||||
public CassandraSchemaElementExistsException(String elementName, ElementType elementType, String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
this.elementName = elementName;
|
||||
this.elementType = elementType;
|
||||
|
||||
@@ -17,18 +17,15 @@
|
||||
package org.springframework.data.cassandra.core.exceptions;
|
||||
|
||||
/**
|
||||
* Spring data access exception for when a Cassandra table being created already
|
||||
* exists.
|
||||
* Spring data access exception for when a Cassandra table being created already exists.
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
public class CassandraTableExistsException extends
|
||||
CassandraSchemaElementExistsException {
|
||||
public class CassandraTableExistsException extends CassandraSchemaElementExistsException {
|
||||
|
||||
private static final long serialVersionUID = 6032967419751410352L;
|
||||
|
||||
public CassandraTableExistsException(String tableName, String msg,
|
||||
Throwable cause) {
|
||||
public CassandraTableExistsException(String tableName, String msg, Throwable cause) {
|
||||
super(tableName, ElementType.TABLE, msg, cause);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,7 @@ import org.springframework.dao.TransientDataAccessException;
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
public class CassandraTraceRetrievalException extends
|
||||
TransientDataAccessException {
|
||||
public class CassandraTraceRetrievalException extends TransientDataAccessException {
|
||||
|
||||
private static final long serialVersionUID = -3163557220324700239L;
|
||||
|
||||
|
||||
@@ -23,8 +23,7 @@ import org.springframework.dao.TypeMismatchDataAccessException;
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
public class CassandraTypeMismatchException extends
|
||||
TypeMismatchDataAccessException {
|
||||
public class CassandraTypeMismatchException extends TypeMismatchDataAccessException {
|
||||
|
||||
private static final long serialVersionUID = -7420058975444905629L;
|
||||
|
||||
|
||||
@@ -19,13 +19,11 @@ package org.springframework.data.cassandra.core.exceptions;
|
||||
import org.springframework.dao.PermissionDeniedDataAccessException;
|
||||
|
||||
/**
|
||||
* Spring data access exception for when access to a Cassandra element is
|
||||
* denied.
|
||||
* Spring data access exception for when access to a Cassandra element is denied.
|
||||
*
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
public class CassandraUnauthorizedException extends
|
||||
PermissionDeniedDataAccessException {
|
||||
public class CassandraUnauthorizedException extends PermissionDeniedDataAccessException {
|
||||
|
||||
private static final long serialVersionUID = 4618185356687726647L;
|
||||
|
||||
|
||||
@@ -29,8 +29,7 @@ public class CassandraWriteTimeoutException extends QueryTimeoutException {
|
||||
|
||||
private String writeType;
|
||||
|
||||
public CassandraWriteTimeoutException(String writeType, String msg,
|
||||
Throwable cause) {
|
||||
public CassandraWriteTimeoutException(String writeType, String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
this.writeType = writeType;
|
||||
}
|
||||
|
||||
@@ -5,5 +5,5 @@ public abstract class CQLBuilder {
|
||||
public static CreateTable createTable(String tableName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -38,15 +38,15 @@ import org.springframework.util.StringUtils;
|
||||
* @author Alex Shvid
|
||||
*/
|
||||
public class BasicCassandraPersistentEntity<T> extends BasicPersistentEntity<T, CassandraPersistentProperty> implements
|
||||
CassandraPersistentEntity<T>, ApplicationContextAware {
|
||||
CassandraPersistentEntity<T>, ApplicationContextAware {
|
||||
|
||||
private final String table;
|
||||
private final SpelExpressionParser parser;
|
||||
private final StandardEvaluationContext context;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new {@link BasicCassandraPersistentEntity} with the given {@link TypeInformation}. Will default the
|
||||
* table name to the entities simple type name.
|
||||
* Creates a new {@link BasicCassandraPersistentEntity} with the given {@link TypeInformation}. Will default the table
|
||||
* name to the entities simple type name.
|
||||
*
|
||||
* @param typeInformation
|
||||
*/
|
||||
@@ -67,7 +67,7 @@ CassandraPersistentEntity<T>, ApplicationContextAware {
|
||||
this.table = fallback;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
|
||||
@@ -78,7 +78,7 @@ CassandraPersistentEntity<T>, ApplicationContextAware {
|
||||
context.setBeanResolver(new BeanFactoryResolver(applicationContext));
|
||||
context.setRootObject(applicationContext);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the table the entity shall be persisted to.
|
||||
*
|
||||
@@ -88,7 +88,7 @@ CassandraPersistentEntity<T>, ApplicationContextAware {
|
||||
Expression expression = parser.parseExpression(table, ParserContext.TEMPLATE_EXPRESSION);
|
||||
return expression.getValue(context, String.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@link Comparator} implementation inspecting the {@link CassandraPersistentProperty}'s order.
|
||||
*
|
||||
@@ -113,8 +113,8 @@ CassandraPersistentEntity<T>, ApplicationContextAware {
|
||||
}
|
||||
|
||||
return o1.getColumnName().compareTo(o2.getColumnName());
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -34,9 +34,9 @@ import com.datastax.driver.core.DataType;
|
||||
*
|
||||
* @author Alex Shvid
|
||||
*/
|
||||
public class BasicCassandraPersistentProperty extends AnnotationBasedPersistentProperty<CassandraPersistentProperty> implements
|
||||
CassandraPersistentProperty {
|
||||
|
||||
public class BasicCassandraPersistentProperty extends AnnotationBasedPersistentProperty<CassandraPersistentProperty>
|
||||
implements CassandraPersistentProperty {
|
||||
|
||||
/**
|
||||
* Creates a new {@link BasicCassandraPersistentProperty}.
|
||||
*
|
||||
@@ -49,7 +49,7 @@ CassandraPersistentProperty {
|
||||
CassandraPersistentEntity<?> owner, SimpleTypeHolder simpleTypeHolder) {
|
||||
super(field, propertyDescriptor, owner, simpleTypeHolder);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Also considers fields that has a RowId annotation.
|
||||
*
|
||||
@@ -63,16 +63,16 @@ CassandraPersistentProperty {
|
||||
|
||||
return getField().isAnnotationPresent(RowId.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* For dynamic tables returns true if property value is used as column name.
|
||||
* For dynamic tables returns true if property value is used as column name.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isColumnId() {
|
||||
return getField().isAnnotationPresent(ColumnId.class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the column name to be used to store the value of the property inside the Cassandra.
|
||||
*
|
||||
@@ -82,7 +82,7 @@ CassandraPersistentProperty {
|
||||
Column annotation = getField().getAnnotation(Column.class);
|
||||
return annotation != null && StringUtils.hasText(annotation.value()) ? annotation.value() : field.getName();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the data type information if exists.
|
||||
*
|
||||
@@ -96,21 +96,23 @@ CassandraPersistentProperty {
|
||||
if (isMap()) {
|
||||
List<TypeInformation<?>> args = getTypeInformation().getTypeArguments();
|
||||
ensureTypeArguments(args.size(), 2);
|
||||
return DataType.map(autodetectPrimitiveType(args.get(0).getType()), autodetectPrimitiveType(args.get(1).getType()));
|
||||
return DataType.map(autodetectPrimitiveType(args.get(0).getType()),
|
||||
autodetectPrimitiveType(args.get(1).getType()));
|
||||
}
|
||||
if (isCollectionLike()) {
|
||||
List<TypeInformation<?>> args = getTypeInformation().getTypeArguments();
|
||||
ensureTypeArguments(args.size(), 1);
|
||||
if (Set.class.isAssignableFrom(getType())) {
|
||||
return DataType.set(autodetectPrimitiveType(args.get(0).getType()));
|
||||
}
|
||||
else if (List.class.isAssignableFrom(getType())) {
|
||||
return DataType.list(autodetectPrimitiveType(args.get(0).getType()));
|
||||
return DataType.set(autodetectPrimitiveType(args.get(0).getType()));
|
||||
} else if (List.class.isAssignableFrom(getType())) {
|
||||
return DataType.list(autodetectPrimitiveType(args.get(0).getType()));
|
||||
}
|
||||
}
|
||||
DataType dataType = CassandraSimpleTypes.autodetectPrimitive(this.getType());
|
||||
if (dataType == null) {
|
||||
throw new InvalidDataAccessApiUsageException("only primitive types and Set,List,Map collections are allowed, unknown type for property '" + this.getName() + "' type is '" + this.getType() + "' in the entity " + this.getOwner().getName());
|
||||
throw new InvalidDataAccessApiUsageException(
|
||||
"only primitive types and Set,List,Map collections are allowed, unknown type for property '" + this.getName()
|
||||
+ "' type is '" + this.getType() + "' in the entity " + this.getOwner().getName());
|
||||
}
|
||||
return dataType;
|
||||
}
|
||||
@@ -118,10 +120,10 @@ CassandraPersistentProperty {
|
||||
private DataType qualifyAnnotatedType(Qualify annotation) {
|
||||
DataType.Name type = annotation.type();
|
||||
if (type.isCollection()) {
|
||||
switch(type) {
|
||||
switch (type) {
|
||||
case MAP:
|
||||
ensureTypeArguments(annotation.typeArguments().length, 2);
|
||||
return DataType.map(resolvePrimitiveType(annotation.typeArguments()[0]),
|
||||
return DataType.map(resolvePrimitiveType(annotation.typeArguments()[0]),
|
||||
resolvePrimitiveType(annotation.typeArguments()[1]));
|
||||
case LIST:
|
||||
ensureTypeArguments(annotation.typeArguments().length, 1);
|
||||
@@ -130,23 +132,23 @@ CassandraPersistentProperty {
|
||||
ensureTypeArguments(annotation.typeArguments().length, 1);
|
||||
return DataType.set(resolvePrimitiveType(annotation.typeArguments()[0]));
|
||||
default:
|
||||
throw new InvalidDataAccessApiUsageException("unknown collection DataType for property '" + this.getName() + "' type is '" + this.getType() + "' in the entity " + this.getOwner().getName());
|
||||
throw new InvalidDataAccessApiUsageException("unknown collection DataType for property '" + this.getName()
|
||||
+ "' type is '" + this.getType() + "' in the entity " + this.getOwner().getName());
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return CassandraSimpleTypes.resolvePrimitive(type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if the property has secondary index on this column.
|
||||
* Returns true if the property has secondary index on this column.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isIndexed() {
|
||||
return getField().isAnnotationPresent(Index.class);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.mapping.model.AbstractPersistentProperty#createAssociation()
|
||||
@@ -159,7 +161,9 @@ CassandraPersistentProperty {
|
||||
DataType resolvePrimitiveType(DataType.Name typeName) {
|
||||
DataType dataType = CassandraSimpleTypes.resolvePrimitive(typeName);
|
||||
if (dataType == null) {
|
||||
throw new InvalidDataAccessApiUsageException("only primitive types are allowed inside collections for the property '" + this.getName() + "' type is '" + this.getType() + "' in the entity " + this.getOwner().getName());
|
||||
throw new InvalidDataAccessApiUsageException(
|
||||
"only primitive types are allowed inside collections for the property '" + this.getName() + "' type is '"
|
||||
+ this.getType() + "' in the entity " + this.getOwner().getName());
|
||||
}
|
||||
return dataType;
|
||||
}
|
||||
@@ -167,17 +171,18 @@ CassandraPersistentProperty {
|
||||
DataType autodetectPrimitiveType(Class<?> javaType) {
|
||||
DataType dataType = CassandraSimpleTypes.autodetectPrimitive(javaType);
|
||||
if (dataType == null) {
|
||||
throw new InvalidDataAccessApiUsageException("only primitive types are allowed inside collections for the property '" + this.getName() + "' type is '" + this.getType() + "' in the entity " + this.getOwner().getName());
|
||||
throw new InvalidDataAccessApiUsageException(
|
||||
"only primitive types are allowed inside collections for the property '" + this.getName() + "' type is '"
|
||||
+ this.getType() + "' in the entity " + this.getOwner().getName());
|
||||
}
|
||||
return dataType;
|
||||
}
|
||||
|
||||
void ensureTypeArguments(int args, int expected) {
|
||||
if (args != expected) {
|
||||
throw new InvalidDataAccessApiUsageException("expected " + expected + " of typed arguments for the property '" + this.getName() + "' type is '" + this.getType() + "' in the entity " + this.getOwner().getName());
|
||||
}
|
||||
throw new InvalidDataAccessApiUsageException("expected " + expected + " of typed arguments for the property '"
|
||||
+ this.getName() + "' type is '" + this.getType() + "' in the entity " + this.getOwner().getName());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.lang.reflect.Field;
|
||||
|
||||
import org.springframework.data.mapping.model.SimpleTypeHolder;
|
||||
|
||||
|
||||
/**
|
||||
* {@link CassandraPersistentProperty} caching access to {@link #isIdProperty()} and {@link #getColumnName()}.
|
||||
*
|
||||
@@ -32,7 +31,7 @@ public class CachingCassandraPersistentProperty extends BasicCassandraPersistent
|
||||
private Boolean isColumnId;
|
||||
private String columnName;
|
||||
private Boolean isIndexed;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new {@link CachingCassandraPersistentProperty}.
|
||||
*
|
||||
@@ -45,7 +44,7 @@ public class CachingCassandraPersistentProperty extends BasicCassandraPersistent
|
||||
CassandraPersistentEntity<?> owner, SimpleTypeHolder simpleTypeHolder) {
|
||||
super(field, propertyDescriptor, owner, simpleTypeHolder);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.mongodb.core.mapping.BasicCassandraPersistentProperty#isIdProperty()
|
||||
@@ -59,7 +58,7 @@ public class CachingCassandraPersistentProperty extends BasicCassandraPersistent
|
||||
|
||||
return this.isIdProperty;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.mongodb.core.mapping.BasicCassandraPersistentProperty#isColumnId()
|
||||
@@ -73,7 +72,7 @@ public class CachingCassandraPersistentProperty extends BasicCassandraPersistent
|
||||
|
||||
return this.isColumnId;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.mongodb.core.mapping.BasicCassandraPersistentProperty#getFieldName()
|
||||
@@ -87,7 +86,7 @@ public class CachingCassandraPersistentProperty extends BasicCassandraPersistent
|
||||
|
||||
return this.columnName;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.mongodb.core.mapping.BasicCassandraPersistentProperty#isIndexed()
|
||||
|
||||
@@ -32,8 +32,9 @@ import org.springframework.data.util.TypeInformation;
|
||||
*
|
||||
* @author Alex Shvid
|
||||
*/
|
||||
public class CassandraMappingContext extends AbstractMappingContext<BasicCassandraPersistentEntity<?>, CassandraPersistentProperty>
|
||||
implements ApplicationContextAware {
|
||||
public class CassandraMappingContext extends
|
||||
AbstractMappingContext<BasicCassandraPersistentEntity<?>, CassandraPersistentProperty> implements
|
||||
ApplicationContextAware {
|
||||
|
||||
private ApplicationContext context;
|
||||
|
||||
@@ -80,5 +81,5 @@ implements ApplicationContextAware {
|
||||
this.context = applicationContext;
|
||||
super.setApplicationContext(applicationContext);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -30,5 +30,5 @@ public interface CassandraPersistentEntity<T> extends PersistentEntity<T, Cassan
|
||||
* @return
|
||||
*/
|
||||
String getTable();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -27,31 +27,31 @@ import com.datastax.driver.core.DataType;
|
||||
public interface CassandraPersistentProperty extends PersistentProperty<CassandraPersistentProperty> {
|
||||
|
||||
/**
|
||||
* For dynamic tables returns true if property value is used as column name.
|
||||
* For dynamic tables returns true if property value is used as column name.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isColumnId();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the name of the field a property is persisted to.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String getColumnName();
|
||||
|
||||
|
||||
/**
|
||||
* Returns the data type.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
DataType getDataType();
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if the property has secondary index on this column.
|
||||
* Returns true if the property has secondary index on this column.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
boolean isIndexed();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -38,11 +38,11 @@ public class CassandraSimpleTypes {
|
||||
private static final Map<Class<?>, Class<?>> primitiveWrapperTypeMap = new HashMap<Class<?>, Class<?>>(8);
|
||||
|
||||
private static final Map<Class<?>, DataType> javaClassToDataType = new HashMap<Class<?>, DataType>();
|
||||
|
||||
|
||||
private static final Map<DataType.Name, DataType> nameToDataType = new HashMap<DataType.Name, DataType>();
|
||||
|
||||
|
||||
static {
|
||||
|
||||
|
||||
primitiveWrapperTypeMap.put(Boolean.class, boolean.class);
|
||||
primitiveWrapperTypeMap.put(Byte.class, byte.class);
|
||||
primitiveWrapperTypeMap.put(Character.class, char.class);
|
||||
@@ -51,7 +51,7 @@ public class CassandraSimpleTypes {
|
||||
primitiveWrapperTypeMap.put(Integer.class, int.class);
|
||||
primitiveWrapperTypeMap.put(Long.class, long.class);
|
||||
primitiveWrapperTypeMap.put(Short.class, short.class);
|
||||
|
||||
|
||||
Set<Class<?>> simpleTypes = new HashSet<Class<?>>();
|
||||
for (DataType dataType : DataType.allPrimitiveTypes()) {
|
||||
simpleTypes.add(dataType.asJavaClass());
|
||||
@@ -72,26 +72,27 @@ public class CassandraSimpleTypes {
|
||||
|
||||
private CassandraSimpleTypes() {
|
||||
}
|
||||
|
||||
|
||||
public static DataType resolvePrimitive(DataType.Name name) {
|
||||
return nameToDataType.get(name);
|
||||
}
|
||||
|
||||
|
||||
public static DataType autodetectPrimitive(Class<?> javaClass) {
|
||||
return javaClassToDataType.get(javaClass);
|
||||
}
|
||||
|
||||
|
||||
public static DataType.Name[] convertPrimitiveTypeArguments(List<TypeInformation<?>> arguments) {
|
||||
DataType.Name[] result = new DataType.Name[arguments.size()];
|
||||
for (int i = 0; i != result.length; ++i) {
|
||||
TypeInformation<?> type = arguments.get(i);
|
||||
DataType dataType = autodetectPrimitive(type.getType());
|
||||
if (dataType == null) {
|
||||
throw new InvalidDataAccessApiUsageException("not found appropriate primitive DataType for type = '" + type.getType());
|
||||
throw new InvalidDataAccessApiUsageException("not found appropriate primitive DataType for type = '"
|
||||
+ type.getType());
|
||||
}
|
||||
result[i] = dataType.getName();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -19,5 +19,5 @@ public @interface Column {
|
||||
* @return
|
||||
*/
|
||||
String value() default "";
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -21,13 +21,13 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Uses in dynamic tables where column names are values of this field.
|
||||
* Usually it is a Date/Time field or UUIDTime field.
|
||||
* Uses in dynamic tables where column names are values of this field. Usually it is a Date/Time field or UUIDTime
|
||||
* field.
|
||||
*
|
||||
* @author Alex Shvid
|
||||
*/
|
||||
@Retention(value=RetentionPolicy.RUNTIME)
|
||||
@Target(value={ElementType.FIELD,ElementType.METHOD,ElementType.ANNOTATION_TYPE})
|
||||
@Retention(value = RetentionPolicy.RUNTIME)
|
||||
@Target(value = { ElementType.FIELD, ElementType.METHOD, ElementType.ANNOTATION_TYPE })
|
||||
public @interface ColumnId {
|
||||
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ import java.lang.annotation.Target;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
/**
|
||||
* Identifies composite row ID in the Cassandra table that contains several
|
||||
* fields. Same as @org.springframework.data.annotation.Id
|
||||
* Identifies composite row ID in the Cassandra table that contains several fields. Same as
|
||||
* @org.springframework.data.annotation.Id
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
|
||||
@@ -24,8 +24,8 @@ import com.datastax.driver.core.DataType;
|
||||
*/
|
||||
public class DataTypeInformation {
|
||||
|
||||
public static DataType.Name[] EMPTY_ATTRIBUTES = {};
|
||||
|
||||
public static DataType.Name[] EMPTY_ATTRIBUTES = {};
|
||||
|
||||
private DataType.Name typeName;
|
||||
private DataType.Name[] typeAttributes;
|
||||
|
||||
@@ -57,8 +57,7 @@ public class DataTypeInformation {
|
||||
public String toCQL() {
|
||||
if (typeAttributes.length == 0) {
|
||||
return typeName.name();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
StringBuilder str = new StringBuilder();
|
||||
str.append(typeName.name());
|
||||
str.append('<');
|
||||
|
||||
@@ -21,15 +21,15 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Identifies a secondary index in the table. Usually it is a field with common dublicate values
|
||||
* for the hole table. such as city, place, educationType, state flags ant etc.
|
||||
* Identifies a secondary index in the table. Usually it is a field with common dublicate values for the hole table.
|
||||
* such as city, place, educationType, state flags ant etc.
|
||||
*
|
||||
* Using unique fields is not common and has overhead, such as email, username and etc.
|
||||
*
|
||||
* @author Alex Shvid
|
||||
*/
|
||||
@Retention(value=RetentionPolicy.RUNTIME)
|
||||
@Target(value={ElementType.FIELD,ElementType.METHOD,ElementType.ANNOTATION_TYPE})
|
||||
@Retention(value = RetentionPolicy.RUNTIME)
|
||||
@Target(value = { ElementType.FIELD, ElementType.METHOD, ElementType.ANNOTATION_TYPE })
|
||||
public @interface Index {
|
||||
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import com.datastax.driver.core.DataType;
|
||||
public @interface Qualify {
|
||||
|
||||
DataType.Name type();
|
||||
|
||||
|
||||
DataType.Name[] typeArguments() default {};
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@ import org.springframework.data.annotation.Id;
|
||||
*
|
||||
* @author Alex Shvid
|
||||
*/
|
||||
@Retention(value=RetentionPolicy.RUNTIME)
|
||||
@Target(value={ElementType.FIELD,ElementType.METHOD,ElementType.ANNOTATION_TYPE})
|
||||
@Retention(value = RetentionPolicy.RUNTIME)
|
||||
@Target(value = { ElementType.FIELD, ElementType.METHOD, ElementType.ANNOTATION_TYPE })
|
||||
@Id
|
||||
public @interface RowId {
|
||||
|
||||
|
||||
@@ -35,5 +35,5 @@ import org.springframework.data.annotation.Persistent;
|
||||
public @interface Table {
|
||||
|
||||
String name() default "";
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -15,37 +15,36 @@ import com.datastax.driver.core.Session;
|
||||
|
||||
public class DriverTests {
|
||||
|
||||
@BeforeClass
|
||||
public static void startCassandra()
|
||||
throws IOException, TTransportException, ConfigurationException, InterruptedException {
|
||||
EmbeddedCassandraServerHelper.startEmbeddedCassandra("cassandra.yaml");
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void startCassandra() throws IOException, TTransportException, ConfigurationException,
|
||||
InterruptedException {
|
||||
EmbeddedCassandraServerHelper.startEmbeddedCassandra("cassandra.yaml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
|
||||
|
||||
Cluster.Builder builder = Cluster.builder().addContactPoint("127.0.0.1");
|
||||
|
||||
//builder.withCompression(ProtocolOptions.Compression.SNAPPY);
|
||||
|
||||
Cluster cluster = builder.build();
|
||||
|
||||
Session session = cluster.connect();
|
||||
|
||||
session.shutdown();
|
||||
|
||||
cluster.shutdown();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@After
|
||||
public void clearCassandra() {
|
||||
EmbeddedCassandraServerHelper.cleanEmbeddedCassandra();
|
||||
}
|
||||
// builder.withCompression(ProtocolOptions.Compression.SNAPPY);
|
||||
|
||||
@AfterClass
|
||||
public static void stopCassandra() {
|
||||
EmbeddedCassandraServerHelper.stopEmbeddedCassandra();
|
||||
}
|
||||
Cluster cluster = builder.build();
|
||||
|
||||
Session session = cluster.connect();
|
||||
|
||||
session.shutdown();
|
||||
|
||||
cluster.shutdown();
|
||||
|
||||
}
|
||||
|
||||
@After
|
||||
public void clearCassandra() {
|
||||
EmbeddedCassandraServerHelper.cleanEmbeddedCassandra();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void stopCassandra() {
|
||||
EmbeddedCassandraServerHelper.stopEmbeddedCassandra();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,8 +32,7 @@ public class CassandraExceptionTranslatorTest {
|
||||
CassandraTableExistsException x = (CassandraTableExistsException) dax;
|
||||
assertEquals(table, x.getTableName());
|
||||
assertEquals(x.getTableName(), x.getElementName());
|
||||
assertEquals(CassandraSchemaElementExistsException.ElementType.TABLE,
|
||||
x.getElementType());
|
||||
assertEquals(CassandraSchemaElementExistsException.ElementType.TABLE, x.getElementType());
|
||||
assertEquals(cx, x.getCause());
|
||||
}
|
||||
|
||||
@@ -49,9 +48,7 @@ public class CassandraExceptionTranslatorTest {
|
||||
CassandraKeyspaceExistsException x = (CassandraKeyspaceExistsException) dax;
|
||||
assertEquals(keyspace, x.getKeyspaceName());
|
||||
assertEquals(x.getKeyspaceName(), x.getElementName());
|
||||
assertEquals(
|
||||
CassandraSchemaElementExistsException.ElementType.KEYSPACE,
|
||||
x.getElementType());
|
||||
assertEquals(CassandraSchemaElementExistsException.ElementType.KEYSPACE, x.getElementType());
|
||||
assertEquals(cx, x.getCause());
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.data.util.ClassTypeInformation;
|
||||
|
||||
|
||||
/**
|
||||
* Unit tests for {@link BasicCassandraPersistentEntity}.
|
||||
*
|
||||
@@ -43,15 +42,14 @@ import org.springframework.data.util.ClassTypeInformation;
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class BasicCassandraPersistentEntityUnitTests {
|
||||
|
||||
|
||||
@Mock
|
||||
ApplicationContext context;
|
||||
|
||||
@BeforeClass
|
||||
public static void startCassandra()
|
||||
throws IOException, TTransportException, ConfigurationException, InterruptedException {
|
||||
EmbeddedCassandraServerHelper.startEmbeddedCassandra("cassandra.yaml");
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void startCassandra() throws IOException, TTransportException, ConfigurationException,
|
||||
InterruptedException {
|
||||
EmbeddedCassandraServerHelper.startEmbeddedCassandra("cassandra.yaml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void subclassInheritsAtDocumentAnnotation() {
|
||||
@@ -84,16 +82,16 @@ public class BasicCassandraPersistentEntityUnitTests {
|
||||
|
||||
assertThat(entity.getTable(), is("user_line"));
|
||||
}
|
||||
|
||||
@After
|
||||
public void clearCassandra() {
|
||||
EmbeddedCassandraServerHelper.cleanEmbeddedCassandra();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void stopCassandra() {
|
||||
EmbeddedCassandraServerHelper.stopEmbeddedCassandra();
|
||||
}
|
||||
@After
|
||||
public void clearCassandra() {
|
||||
EmbeddedCassandraServerHelper.cleanEmbeddedCassandra();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void stopCassandra() {
|
||||
EmbeddedCassandraServerHelper.stopEmbeddedCassandra();
|
||||
}
|
||||
|
||||
@Table(name = "messages")
|
||||
class Message {
|
||||
@@ -115,12 +113,12 @@ public class BasicCassandraPersistentEntityUnitTests {
|
||||
}
|
||||
|
||||
class MappingBean {
|
||||
|
||||
|
||||
String userLine;
|
||||
|
||||
public String getUserLine() {
|
||||
return userLine;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ import org.springframework.data.mapping.model.SimpleTypeHolder;
|
||||
import org.springframework.data.util.ClassTypeInformation;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
|
||||
/**
|
||||
* Unit test for {@link BasicCassandraPersistentProperty}.
|
||||
*
|
||||
@@ -44,12 +43,12 @@ import org.springframework.util.ReflectionUtils;
|
||||
public class BasicCassandraPersistentPropertyUnitTests {
|
||||
|
||||
CassandraPersistentEntity<Timeline> entity;
|
||||
|
||||
@BeforeClass
|
||||
public static void startCassandra()
|
||||
throws IOException, TTransportException, ConfigurationException, InterruptedException {
|
||||
EmbeddedCassandraServerHelper.startEmbeddedCassandra("cassandra.yaml");
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void startCassandra() throws IOException, TTransportException, ConfigurationException,
|
||||
InterruptedException {
|
||||
EmbeddedCassandraServerHelper.startEmbeddedCassandra("cassandra.yaml");
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
@@ -82,16 +81,16 @@ public class BasicCassandraPersistentPropertyUnitTests {
|
||||
assertThat(property.isColumnId(), is(true));
|
||||
}
|
||||
|
||||
@After
|
||||
public void clearCassandra() {
|
||||
EmbeddedCassandraServerHelper.cleanEmbeddedCassandra();
|
||||
}
|
||||
@After
|
||||
public void clearCassandra() {
|
||||
EmbeddedCassandraServerHelper.cleanEmbeddedCassandra();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void stopCassandra() {
|
||||
EmbeddedCassandraServerHelper.stopEmbeddedCassandra();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void stopCassandra() {
|
||||
EmbeddedCassandraServerHelper.stopEmbeddedCassandra();
|
||||
}
|
||||
|
||||
private CassandraPersistentProperty getPropertyFor(Field field) {
|
||||
return new BasicCassandraPersistentProperty(field, null, entity, new SimpleTypeHolder());
|
||||
}
|
||||
@@ -103,10 +102,10 @@ public class BasicCassandraPersistentPropertyUnitTests {
|
||||
|
||||
@ColumnId
|
||||
Date time;
|
||||
|
||||
|
||||
@Column("message")
|
||||
String text;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -26,12 +26,10 @@ import org.springframework.data.cassandra.mapping.Table;
|
||||
import com.datastax.driver.core.DataType;
|
||||
|
||||
/**
|
||||
* This is an example of dynamic table that creates each time new column
|
||||
* with Post timestamp annotated by @ColumnId.
|
||||
* This is an example of dynamic table that creates each time new column with Post timestamp annotated by @ColumnId.
|
||||
*
|
||||
* It is possible to use a static table for posts and identify them by PostId(UUID),
|
||||
* but in this case we need to use MapReduce for Big Data to find posts for
|
||||
* particular user, so it is better to have index (userId) -> index (post time)
|
||||
* It is possible to use a static table for posts and identify them by PostId(UUID), but in this case we need to use
|
||||
* MapReduce for Big Data to find posts for particular user, so it is better to have index (userId) -> index (post time)
|
||||
* architecture. It helps a lot to build eventually a search index for the particular user.
|
||||
*
|
||||
* @author Alex Shvid
|
||||
@@ -49,12 +47,12 @@ public class Comment {
|
||||
* Column ID
|
||||
*/
|
||||
@ColumnId
|
||||
@Qualify(type=DataType.Name.TIMESTAMP)
|
||||
@Qualify(type = DataType.Name.TIMESTAMP)
|
||||
private Date time;
|
||||
|
||||
private String text;
|
||||
|
||||
@Qualify(type=DataType.Name.SET, typeArguments={DataType.Name.TEXT})
|
||||
|
||||
@Qualify(type = DataType.Name.SET, typeArguments = { DataType.Name.TEXT })
|
||||
private Set<String> likes;
|
||||
|
||||
/*
|
||||
|
||||
@@ -23,15 +23,15 @@ import org.springframework.data.cassandra.mapping.RowId;
|
||||
import org.springframework.data.cassandra.mapping.Table;
|
||||
|
||||
/**
|
||||
* This is an example of the Users statis table, where all fields are columns
|
||||
* in Cassandra row. Some fields can be Set,List,Map like emails.
|
||||
* This is an example of the Users statis table, where all fields are columns in Cassandra row. Some fields can be
|
||||
* Set,List,Map like emails.
|
||||
*
|
||||
* User contains base information related for separate user, like
|
||||
* names, additional information, emails, following users, friends.
|
||||
* User contains base information related for separate user, like names, additional information, emails, following
|
||||
* users, friends.
|
||||
*
|
||||
* @author Alex Shvid
|
||||
*/
|
||||
@Table(name="log_entry")
|
||||
@Table(name = "log_entry")
|
||||
public class LogEntry {
|
||||
|
||||
/*
|
||||
@@ -39,9 +39,9 @@ public class LogEntry {
|
||||
*/
|
||||
@RowId
|
||||
private Date logDate;
|
||||
|
||||
|
||||
private String hostname;
|
||||
|
||||
|
||||
private String logData;
|
||||
|
||||
/**
|
||||
@@ -85,5 +85,5 @@ public class LogEntry {
|
||||
public void setLogData(String logData) {
|
||||
this.logData = logData;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -23,12 +23,11 @@ import org.springframework.data.cassandra.mapping.Index;
|
||||
import org.springframework.data.cassandra.mapping.Table;
|
||||
|
||||
/**
|
||||
* This is an example of dynamic table that creates each time new column
|
||||
* with Notification timestamp annotated by @ColumnId.
|
||||
* This is an example of dynamic table that creates each time new column with Notification timestamp annotated by
|
||||
* @ColumnId.
|
||||
*
|
||||
* By default it is active Notification until user deactivate it.
|
||||
* This table uses index on the field active to access in WHERE cause only
|
||||
* for active notifications.
|
||||
* By default it is active Notification until user deactivate it. This table uses index on the field active to access in
|
||||
* WHERE cause only for active notifications.
|
||||
*
|
||||
* @author Alex Shvid
|
||||
*/
|
||||
|
||||
@@ -24,12 +24,10 @@ import org.springframework.data.cassandra.mapping.ColumnId;
|
||||
import org.springframework.data.cassandra.mapping.Table;
|
||||
|
||||
/**
|
||||
* This is an example of dynamic table that creates each time new column
|
||||
* with Post timestamp annotated by @ColumnId.
|
||||
* This is an example of dynamic table that creates each time new column with Post timestamp annotated by @ColumnId.
|
||||
*
|
||||
* It is possible to use a static table for posts and identify them by PostId(UUID),
|
||||
* but in this case we need to use MapReduce for Big Data to find posts for
|
||||
* particular user, so it is better to have index (userId) -> index (post time)
|
||||
* It is possible to use a static table for posts and identify them by PostId(UUID), but in this case we need to use
|
||||
* MapReduce for Big Data to find posts for particular user, so it is better to have index (userId) -> index (post time)
|
||||
* architecture. It helps a lot to build eventually a search index for the particular user.
|
||||
*
|
||||
* @author Alex Shvid
|
||||
|
||||
@@ -22,17 +22,15 @@ import org.springframework.data.cassandra.mapping.ColumnId;
|
||||
import org.springframework.data.cassandra.mapping.Table;
|
||||
|
||||
/**
|
||||
* This is an example of the users timeline dynamic table, where all columns
|
||||
* are dynamically created by @ColumnId field value. The rest fields are places
|
||||
* in Cassandra value.
|
||||
* This is an example of the users timeline dynamic table, where all columns are dynamically created by @ColumnId field
|
||||
* value. The rest fields are places in Cassandra value.
|
||||
*
|
||||
* Timeline entity is used to store user's status updates that it follows in the site.
|
||||
* Timeline always ordered by @ColumnId field and we can retrieve last top status
|
||||
* updates by using limits.
|
||||
* Timeline entity is used to store user's status updates that it follows in the site. Timeline always ordered by @ColumnId
|
||||
* field and we can retrieve last top status updates by using limits.
|
||||
*
|
||||
* @author Alex Shvid
|
||||
*/
|
||||
@Table(name="timeline")
|
||||
@Table(name = "timeline")
|
||||
public class Timeline {
|
||||
|
||||
/*
|
||||
@@ -40,13 +38,13 @@ public class Timeline {
|
||||
*/
|
||||
@Id
|
||||
private String username;
|
||||
|
||||
|
||||
/*
|
||||
* Column ID
|
||||
*/
|
||||
@ColumnId
|
||||
private Date time;
|
||||
|
||||
|
||||
/*
|
||||
* Reference to the post by author and postUID
|
||||
*/
|
||||
@@ -85,5 +83,4 @@ public class Timeline {
|
||||
this.postTime = postTime;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -22,15 +22,15 @@ import org.springframework.data.cassandra.mapping.Index;
|
||||
import org.springframework.data.cassandra.mapping.Table;
|
||||
|
||||
/**
|
||||
* This is an example of the Users statis table, where all fields are columns
|
||||
* in Cassandra row. Some fields can be Set,List,Map like emails.
|
||||
* This is an example of the Users statis table, where all fields are columns in Cassandra row. Some fields can be
|
||||
* Set,List,Map like emails.
|
||||
*
|
||||
* User contains base information related for separate user, like
|
||||
* names, additional information, emails, following users, friends.
|
||||
* User contains base information related for separate user, like names, additional information, emails, following
|
||||
* users, friends.
|
||||
*
|
||||
* @author Alex Shvid
|
||||
*/
|
||||
@Table(name="users")
|
||||
@Table(name = "users")
|
||||
public class User {
|
||||
|
||||
/*
|
||||
@@ -38,40 +38,40 @@ public class User {
|
||||
*/
|
||||
@Id
|
||||
private String username;
|
||||
|
||||
|
||||
/*
|
||||
* Public information
|
||||
*/
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
|
||||
|
||||
/*
|
||||
* Secondary index, used only on fields with common information,
|
||||
* not effective on email, username
|
||||
*/
|
||||
@Index
|
||||
private String place;
|
||||
|
||||
|
||||
/*
|
||||
* User emails
|
||||
*/
|
||||
private Set<String> emails;
|
||||
|
||||
|
||||
/*
|
||||
* Password
|
||||
*/
|
||||
private String password;
|
||||
|
||||
|
||||
/*
|
||||
* Age
|
||||
*/
|
||||
private int age;
|
||||
|
||||
|
||||
/*
|
||||
* Following other users in userline
|
||||
*/
|
||||
private Set<String> following;
|
||||
|
||||
|
||||
/*
|
||||
* Friends of the user
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user