Tuesday, May 31, 2016
Thursday, May 26, 2016
Tuesday, May 24, 2016
Spring Blog
- http://briansjavablog.blogspot.com/2013/01/spring-web-services-tutorial.html
- https://github.com/roghughe/captaindebug
- https://www.javacodegeeks.com/2013/06/java-security-tutorial-step-by-step-guide-to-create-ssl-connection-and-certificates.html
- http://www.softwareengineeringsolutions.com/blogs/2010/08/13/asynchronous-servlets-in-servlet-spec-3-0/
- http://errai-blog.blogspot.it/2011/10/jax-rs-in-gwt-with-errai.html
- https://github.com/niclabs
- https://opennlp.apache.org/documentation/1.6.0/manual/opennlp.html#tools.tokenizer.training.tool
- http://www.wideskills.com/java-tutorial
- http://stackoverflow.com/users/1240763/gary-russell
Sunday, May 22, 2016
Friday, May 20, 2016
Java transfer content from one file to another
http://www.programcreek.com/2011/03/java-transfer-content-from-one-file-to-another/
package com.aaa.fileDataTransfer;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
public class FileDataModTransfer {
public static void main(String[] args) throws IOException {
String source = "F://fileDataInput.txt";
String dest = "F://fileDataOutput.txt";
File fin = new File(source);
FileInputStream fis = new FileInputStream(fin);
BufferedReader in = new BufferedReader(new InputStreamReader(fis));
FileWriter fstream = new FileWriter(dest, true);
BufferedWriter out = new BufferedWriter(fstream);
String aLine = null;
while ((aLine = in.readLine()) != null) {
// Process each line and add output to Dest.txt file
String[] parts = aLine.split(" ");
System.out.println("First Part: " + parts[0]);
System.out.println("Second Part: " + parts[1]);
String generatedLine = "(" + parts[0] + ", '" + parts[1] + "'),";
System.out.println(generatedLine.toString());
out.write(generatedLine);
out.newLine();
}
// do not forget to close the buffer reader
in.close();
// close buffer writer
out.close();
}
}
INPUT: F://fileDataInput.txt
88 baikaName_88
89 baikaName_89
90 baikaName_90
OUTPUT:F://fileDataOutput.txt
(88, 'baikaName_88'),
(89, 'baikaName_89'),
(90, 'baikaName_90'),
package com.aaa.fileDataTransfer;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
public class FileDataModTransfer {
public static void main(String[] args) throws IOException {
String source = "F://fileDataInput.txt";
String dest = "F://fileDataOutput.txt";
File fin = new File(source);
FileInputStream fis = new FileInputStream(fin);
BufferedReader in = new BufferedReader(new InputStreamReader(fis));
FileWriter fstream = new FileWriter(dest, true);
BufferedWriter out = new BufferedWriter(fstream);
String aLine = null;
while ((aLine = in.readLine()) != null) {
// Process each line and add output to Dest.txt file
String[] parts = aLine.split(" ");
System.out.println("First Part: " + parts[0]);
System.out.println("Second Part: " + parts[1]);
String generatedLine = "(" + parts[0] + ", '" + parts[1] + "'),";
System.out.println(generatedLine.toString());
out.write(generatedLine);
out.newLine();
}
// do not forget to close the buffer reader
in.close();
// close buffer writer
out.close();
}
}
INPUT: F://fileDataInput.txt
88 baikaName_88
89 baikaName_89
90 baikaName_90
OUTPUT:F://fileDataOutput.txt
(88, 'baikaName_88'),
(89, 'baikaName_89'),
(90, 'baikaName_90'),
Postgresql Backup of single table
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserve
C:\Users\USER>cd C:\Program Files (x86)\PostgreSQL\9.2\bin
C:\Program Files (x86)\PostgreSQL\9.2\bin> pg_dump --host localhost --port 5432 --username postgres --format plain --ignore-version --verbose --file "F:\tm_baikanol.backup" --table public.tm_baikanol mog001
Copyright (c) 2009 Microsoft Corporation. All rights reserve
C:\Users\USER>cd C:\Program Files (x86)\PostgreSQL\9.2\bin
C:\Program Files (x86)\PostgreSQL\9.2\bin> pg_dump --host localhost --port 5432 --username postgres --format plain --ignore-version --verbose --file "F:\tm_baikanol.backup" --table public.tm_baikanol mog001
Best Null Pointer Checking
List<Mst00202> zaikolist =
this.mst002Logic.findZaikoByScode(request.scode);
if (zaikolist != null && !zaikolist.isEmpty() && zaikolist.size() > 0) {
this.mst002Logic.findZaikoByScode(request.scode);
if (zaikolist != null && !zaikolist.isEmpty() && zaikolist.size() > 0) {
Thursday, May 19, 2016
My Questions and Answers
Related to Java: http://stackoverflow.com/search?q=user:2293534+[java]
Related to JAVA, Hibernate and Spring: http://stackoverflow.com/search?q=user:2293534+[java]+[hibernate]+[Spring]
Related to JAVA, Hibernate and Spring: http://stackoverflow.com/search?q=user:2293534+[java]+[hibernate]+[Spring]
2 way SSL
- http://www.robinhowlett.com/blog/2016/01/05/everything-you-ever-wanted-to-know-about-ssl-but-were-afraid-to-ask/
- http://stackoverflow.com/questions/33808603/implementing-2-way-ssl-using-spring-boot
- http://stackoverflow.com/questions/6441523/spring-security-how-to-force-https-with-flag
- https://developer.salesforce.com/page/Making_Authenticated_Web_Service_Callouts_Using_Two-Way_SSL
- https://github.com/viniciusccarvalho/boot-two-way-ssl-example
- https://dzone.com/articles/2-way-ssl-java-keystore
- https://edlee.me/2012/09/04/two-way-ssl-restful-service-using-apache-cxf/
- https://jeromebulanadi.wordpress.com/2010/02/25/basic-spring-web-service-tutorial-from-contract-to-security/#server_security
- http://crunchify.com/step-by-step-guide-to-enable-https-or-ssl-correct-way-on-apache-tomcat-server-port-8443/
Criteria API URL
- http://www.ibm.com/developerworks/java/library/j-typesafejpa/
- http://stackoverflow.com/questions/4483576/jpa-2-0-criteria-api-subqueries-in-expressions
- https://wiki.ssdt-ohio.org/display/~springer/2014/04/14/JPA+Criteria+Queries+-+Predicates+and+Subqueries
- http://www.objectdb.com/java/jpa/query/jpql/update
- https://docs.oracle.com/cd/E19798-01/821-1841/gjitv/index.html
- https://www.jumpingbean.co.za/blogs/jpa2-criteria-api
Wednesday, May 18, 2016
JPA Criteria API by samples – Part-II
JPA Criteria API by samples – Part-II
you can read first part from JPA Criteria API by samples – Part-I
some more examples with JPA criteria API
Simple Join query
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| long category=200L; Query query = entityManager.createQuery( "select s from OrderItem s " + "where s.product.category=:cat" ); query.setParameter( "cat" , category); List<OrderItem> list = query.getResultList(); CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaQuery<Object> criteriaQuery = criteriaBuilder.createQuery(); Root<OrderItem> from = criteriaQuery.from(OrderItem. class ); Path<Object> path = from.join( "product" ).get( "category" ); CriteriaQuery<Object> select = criteriaQuery.select(from); select.where(criteriaBuilder.equal(path, category)); TypedQuery<Object> typedQuery = entityManager.createQuery(select); List<Object> resultList = typedQuery.getResultList(); assertEqualsList(list, resultList); |
simple fetch join query
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| long category=200L; Query query = entityManager.createQuery( "select s from OrderItem s " + "join fetch s.product where s.product.category=:cat" ); query.setParameter( "cat" , category); List<OrderItem> list = query.getResultList(); CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaQuery<Object> criteriaQuery = criteriaBuilder.createQuery(); Root<OrderItem> from = criteriaQuery.from(OrderItem. class ); Path<Object> path = from.join( "product" ).get( "category" ); from.fetch( "product" ); //FETCH product CriteriaQuery<Object> select = criteriaQuery.select(from); select.where(criteriaBuilder.equal(path, category)); TypedQuery<Object> typedQuery = entityManager.createQuery(select); List<Object> resultList = typedQuery.getResultList(); assertEqualsList(list, resultList); |
subselect (subquery) join query
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| Query query = entityManager.createQuery( "select s from OrderItem s join fetch s.product" + " where s.product.category in" + " (select sb.pbyte from SimpleBean sb where sb.pint>=30000)" ); List<OrderItem> list = query.getResultList(); CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder(); CriteriaQuery<Object> criteriaQuery = criteriaBuilder.createQuery(); Root<OrderItem> from = criteriaQuery.from(OrderItem. class ); Path<Object> path = from.join( "product" ).get( "category" ); from.fetch( "product" ); CriteriaQuery<Object> select = criteriaQuery.select(from); Subquery<SimpleBean> subquery = criteriaQuery.subquery(SimpleBean. class ); Root fromSimpleBean = subquery.from(SimpleBean. class ); subquery.select(fromSimpleBean.get( "pbyte" )); subquery.where(criteriaBuilder.ge(fromSimpleBean.get( "pint" ), 30000 )); select.where(criteriaBuilder.in(path).value(subquery)); TypedQuery<Object> typedQuery = entityManager.createQuery(select); List<Object> resultList = typedQuery.getResultList(); assertEqualsList(list, resultList); |
Subscribe to:
Posts (Atom)