//java code如下
TypedQuery<?> outputSql = entityManager.createQuery(query);
org.eclipse.persistence.sessions.Session session = communityEm.unwrap(org.eclipse.persistence.jpa.JpaEntityManager.class).getActiveSession();
org.eclipse.persistence.queries.DatabaseQuery databaseQuery = outputSql.unwrap(org.eclipse.persistence.jpa.JpaQuery.class).getDatabaseQuery();
databaseQuery.prepareCall(session, new org.eclipse.persistence.sessions.DatabaseRecord());
System.out.println("databaseQuery.getSQLString()"+databaseQuery.getSQLString());
月份:2019年11月
Idea工具常用快捷键
- 优化 import java classes
//消除不用的 import classes
Shift+Command + A , then Enter
- Find java file
Control + Shift + O
- Find keyword in projects
Control + Shift + F
Mave/git issue fixed 例子
- 当 maven compile code时, 下载很多的resource files时, 怎样略过如下
mvn clean compile -o install
- 开发免不了进行代码review,当遇到git提交出现 ‘Changes not staged for commit’ 问题的解决方法
Cases are
1) when pull from remote branch1
2) Modify and submit, then push to remote branch2
3) Remote branch2 updated some files, and local branch modified
4) Cant submit and push to remote branch2 now
Solution steps:
1) Check out new local branch from remote branch2
2) Modify new local branch and submit & push to remote branch2
3) After merge to remote branch1(e.g. master branch), remove old local branch and checkout from remote branch
4) Remove the local branch which pushes to remote branch2
用java JPA进行多表join
例如我们有如下多表查询
select A.id, A.name, B.name2, C.name2 from A,B,C where A.id=B.bid and B.name3 = C.id
我们用Join连接 JPA tables
// Root rootpath Entity A,B,C in B has relasionship B.name3 = C Join b_path = rootpath.join("id");
Join c_path = b_path.join("name3");
Java 小知识
1. Get client timezone
Calendar.getInstance().getTimeZone()
2. JPA sql 输出
//queryType:TypedQuery