Skip to content

Instantly share code, notes, and snippets.

@Bean(name = "jdbcTemplateForFileH2DataBaseInRealisation")
public JdbcTemplate buildTemplate() throws SQLException, IOException {
try {
// For server with classpath: WEB-INF/classes/init_db2
RunScript.execute(dataSource.getConnection(), new FileReader(new ClassPathResource("init_db2").getFile()));
} catch (final IOException e) {
LOGGER.error("new ClassPathResource(\"init_db2\").getFile() NOT FOUND. USING CONFIGURATION FOR LOCAL MACHINE." , e);
// For local machine with resource: ./src/main/resources/init_db2
RunScript.execute(dataSource.getConnection(), new FileReader("./src/main/resources/init_db2"));
}
/**
* Gets List<T> from Mvc result Json path.
*
* @param mvcResult - MvcResult from resource test
* @param listJsonPath - list Json path
* @param <T> - types of elements of the list
* @return List<T>
*/
public <T> List<T> getListFromMvcResultJsonPath(final MvcResult mvcResult, final JsonPath listJsonPath) {
@SuppressWarnings("Not presented method findByTwoLetterCode(). Fix it in shortest possible time.")
@Ignore
@Test
public void testFindByTwoLetterCode() {
CountryData countryData = new CountryData();
String twoLetterCode = "AZ";
countryData.code2 = twoLetterCode;
Long countryId = countryDB.create(countryData);
Country country = countryDB.findByTwoLetterCode("AZ");
Assert.assertEquals(countryId, country.id);
@gitjs77
gitjs77 / SearchQueryWithProjectionsConstructor.java
Last active September 27, 2017 11:06
JPA @query with search to Querydsl with Projections.constructor
/* SQLQueryFactory for Querydsl querying*/
private SQLQueryFactory queryFactory;
/* Q - generated objects for use in the Querydsl querying*/
private static QCard card = QCard.card;
private static QAccounts account = QAccounts.accounts;
private static QCustomer customer = QCustomer.customer;
private static QBankBranch bankBranch = QBankBranch.bankBranch;
/**
* Gets accounts by parameters and searchText term.
@gitjs77
gitjs77 / SearchQueryWithTuple.java
Last active September 27, 2017 10:57
JPA @query with search to QueryDSL with Tuple
/* SQLQueryFactory for Querydsl querying8*/
private SQLQueryFactory queryFactory;
/* Q - generated objects for use in the Querydsl querying*/
private static QDeposit deposit = QDeposit.deposit;
private static QAccounts account = QAccounts.accounts;
private static QCustomer customer = QCustomer.customer;
/*@Query("select u from Deposit u" +
" where (u.currency=:depositCurrency or :depositCurrency is null)" +
"and(u.depositType=:depositType or :depositType is null)" +
import java.sql.SQLException;
public class ConstructorWithExceptions {
public class Parent {
public Parent() throws SQLException {
}
public void method() throws Exception {
}
public class IntegerPool {
public static void main(String[] args) {
Integer i1 = 10;
Integer i2 = 10;
System.out.println(i1 == i2);// true, value < 128
System.out.println("======================");
Integer i3 = 300;
Integer i4 = 300;
System.out.println(i3 == i4); // false, value >= 128
renderOrganization(doc) {
return <div>
<span
style={ { fontSize: '14px' } }>{ highlight(doc.card.account.customer.organization.name, this.state.filter.searchText) }</span>
<br/>
<span>{ translate('common_TaxCode') }: { highlight(doc.card.account.customer.organization.taxCode, this.state.filter.searchText) } </span>
</div>;
}
fetchRows = window => {
if (window['groupId'] === null || window['groupId'] === undefined || window['groupId'] === 0) {
delete window['groupId'];
}
return get('/constants', this.isFilterNotEmpty() ? window : Object.assign(window, { sort: 'propertyGroupId', order: 'asc' }));
}
public Long setCardDisplayOrder(final Long cardId, final Double displayOrder) {
if (cardId == null || cardId == 0 || displayOrder == null) return 0L;
return cardRepositoryDB.setCardDisplayOrder(cardId, displayOrder);
}