Skip to main content

Home/ Java Development/ Group items tagged query

Rss Feed Group items tagged

anonymous

1. Working with Spring Data Repositories - 0 views

  • Typically, your repository interface will extend Repository, CrudRepository or PagingAndSortingRepository. Alternatively, if you do not want to extend Spring Data interfaces, you can also annotate your repository interface with @RepositoryDefinition
  • It allows quick query definition by method names but also custom-tuning of these queries by introducing declared queries as needed.
  • CREATE_IF_NOT_FOUND (default)CREATE_IF_NOT_FOUND combines CREATE and USE_DECLARED_QUERY.
  • ...21 more annotations...
  • the first By acts as delimiter to indicate the start of the actual criteria
  • The mechanism strips the prefixes find…By, read…By, and get…By from the method and starts parsing the rest of it
  • you can define conditions on entity properties and concatenate them with And and Or
  • The introducing clause can contain further expressions such as a Distinct to set a distinct flag
  • List<Person> findByEmailAddressAndLastname(EmailAddress emailAddress, String lastname); // Enables the distinct flag for the query List<Person> findDistinctPeopleByLastnameOrFirstname(String lastname, String firstname); List<Person> findPeopleDistinctByLastnameOrFirstname(String lastname, String firstname); // Enabling ignoring case for an individual property List<Person> findByLastnameIgnoreCase(String lastname); // Enabling ignoring case for all suitable properties List<Person> findByLastnameAndFirstnameAllIgnoreCase(String lastname, String firstname); // Enabling static ORDER BY for a query List<Person> findByLastnameOrderByFirstnameAsc(String lastname); List<Person> findByLastnameOrderByFirstnameDesc(String lastname);
  • You can combine property expressions with AND and OR. You also get support for operators such as Between, LessThan, GreaterThan, Like for the property expressions
  • AllIgnoreCase
  • IgnoreCase
  • The resolution algorithm starts with interpreting the entire part (AddressZipCode) as the property and checks the domain class for a property with that name (uncapitalized). If the algorithm succeeds it uses that property. If not, the algorithm splits up the source at the camel case parts from the right side into a head and a tail and tries to find the corresponding property, in our example, AddressZip and Code.
  • he infrastructure will recognize certain specific types like Pageable and Sort to apply pagination and sorting to your queries dynamically
  • Pageable
  • Sort sort
  • The first method allows you to pass an org.springframework.data.domain.Pageable instance to the query method to dynamically add paging to your statically defined query. Sorting options are handled through the Pageable instance too
  • <repositories base-package="com.acme.repositories" />
  • Spring is instructed to scan com.acme.repositories and all its subpackages for interfaces extending Repository or one of its subinterfaces. For each interface found, the infrastructure registers the persistence technology-specific FactoryBean to create the appropriate proxies that handle invocations of the query methods. Each bean is registered under a bean name that is derived from the interface name, so an interface of UserRepository would be registered under userRepository
  • This postfix defaults to Impl.Example 1.12. Configuration example<repositories base-package="com.acme.repository" /> <repositories base-package="com.acme.repository" repository-impl-postfix="FooBar" />The first configuration example will try to look up a class com.acme.repository.UserRepositoryImpl to act as custom repository implementation, where the second example will try to lookup com.acme.repository.UserRepositoryFoo
  • To exclude an interface that extends Repository from being instantiated as a repository instance, you can either annotate it with @NoRepositoryBean or move it outside of the configured base-package.
  • ]In general, the integration support is enabled by using the @EnableSpringDataWebSupport annotation in your JavaConfig configuration class.
  • @Configuration @EnableWebMvc @EnableSpringDataWebSupport class WebConfiguration { }
  • In case you need multiple Pageables or Sorts to be resolved from the request (for multiple tables, for example) you can use Spring's @Qualifier annotation to distinguish one from another
  • Spring HATEOAS ships with a representation model class PagedResources that allows enrichting the content of a Page instance with the necessary Page metadata as well as links to let the clients easily navigate the pages.
Hendy Irawan

Querydsl - 0 views

  •  
    Querydsl is a framework which enables the construction of type-safe SQL-like queries for multiple backends including JPA, JDO and SQL in Java. Instead of writing queries as inline strings or externalizing them into XML files they are constructed via a fluent API. Code completion in IDE (all properties, methods and operations can be expanded in your favorite Java IDE) Almost no syntactically invalid queries allowed (type-safe on all levels) Domain types and properties can be referenced safely (no Strings involved!) Adopts better to refactoring changes in domain types Incremental query definition is easier Querydsl is licensed under the LGPL 2.1 license.
anonymous

squill: Home - 2 views

  •  
    Squill is a slick internal DSL for writing SQL queries in pure Java. It uses the database metadata and generics to catch as many errors as possible during compilation and is almost completely typesafe. At the same time it is designed to allow everything SQL allows you to do, exactly the way SQL is meant to do it. This means that you're encouraged to select only the data you need and no hidden queries are generated for you, leaving you in full control of the query performance. Squill also supports database-specific extensions, allowing you to both use advanced features and fully tweak your queries.
Hendy Irawan

SQL Workbench/J -  Home - 0 views

  •  
    SQL Workbench/J is a free, DBMS-independent, cross-platform SQL query tool. It is written in Java and thus it should run on any operating system that provides a Java Runtime Environment. It's main focus is on running SQL scripts (either interactively or as a batch) and export/import features. Graphical query building or more advanced DBA tasks are not the focus and are not planned Current stable version: Build 110 (2011-02-13) Current development build: 110.5 ( 2011-04-25)
mahesh 1234

Hibernate Tutorial - javatpoint - 0 views

  •  
    Hibernate Tutorial. In this hibernate tutorial, we will learn basics of hibernate, inheritance mapping, collection mapping, component mapping, HQL, HCQL, Named Query, Caching and Integration of Hibernate with other frameworks.
anonymous

reflections - Google Code - 0 views

  •  
    Reflections scans your classpath, indexes the metadata, allows you to query it on runtime and may save and collect that information for many modules within your project.
Hendy Irawan

jaxen: universal Java XPath engine - jaxen - 0 views

  •  
    "Jaxen is an open source XPath library written in Java. It is adaptable to many different object models, including DOM, XOM, dom4j, and JDOM. Is it also possible to write adapters that treat non-XML trees such as compiled Java byte code or Java beans as XML, thus enabling you to query these trees with XPath too. "
sureshstalin

Sr. Sharepoint Developer with Sql Experience - 0 views

  •  
    JOB SUMMARY: This Senior Programmer/Analyst is responsible for the design, development and documentation of SharePoint applications as well as devlelopment and support of organizationl reports and data queries. Reports are typically developed in Crystal Reports. This position is also responsible for the support and maintenance of the Crystal Enterprise environment.
Hendy Irawan

Getting started with Spring Data JPA | SpringSource Team Blog - 0 views

  •  
    As we have just released the first milestone of the Spring Data JPA project I'd like to give you a quick introduction into its features. As you probably know, the Spring framework provides support to build a JPA based data access layer. So what does Spring Data JPA add to this base support? To answer that question I'd like to start with the data access components for a sample domain implemented using plain JPA + Spring and point out areas that leave room for improvement. After we've done that I will refactor the implementations to use the Spring Data JPA features to address these problem areas. The sample project as well as a step by step guide of the refactoring steps can be found on Github.
1 - 10 of 10
Showing 20 items per page