- 8月 10 週五 201813:32
Create a Multi Language web application with Spring Boot & FreeMarker
使用 Hibernate Tool 產生 Model 時, FetchType 預設是 FetchType.LAZY , 但在執行時, 卻常會產生類似下列 no Session 的錯誤訊息
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: com.spring.jwt.db.maria.model.authentication.User.userAuthorities, could not initialize proxy - no Session
這時候需要在 Method 前加入 @Transactional 就可以解決
@Test @Transactional public void testUserAuthority() { User user = userRepository.findById(1L).get(); JwtUser jwtUser = JwtUserFactory.create(user); logger.info(jwtUser.getUsername()); } - 5月 10 週四 201811:29
Spring Boot 2 and H2 with gradle
使用 Spring Boot 2 建置系統就是希望快速. 若專案範圍小的話, 資料庫倒是可以考慮使用 H2 database 來建罝
在 build.gradle 上加入
compile('com.h2database:h2') 然後編輯 application.properties
server.port=8088 # =============================== # H2 # =============================== spring.h2.console.enabled=true spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE spring.datasource.driverClassName=org.h2.Driver spring.datasource.username=sa spring.datasource.password= spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
- 9月 01 週五 201714:04
Yii2 Advanced For Multiple database & Oracle DB 多資料庫設定
- 7月 21 週五 201710:03
JBoss EAP 6 and Tomcat 8.5 Virtual Directories Configure 虛擬目錄設定方式
- 5月 13 週六 201718:44
eclipse pydev django 在 windows 10 的開發環境配置
環境:
eclipse : https://eclipse.org/downloads/packages/release/Neon/3
python: Python 3.6.1
django: Django-1.11.1.tar.gz
先下載 Python 3.6.1 安裝在 C:\Python\Python36-32 然後增加 Path
- 5月 04 週四 201714:59
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role 解決方法
用 Hibernet Tool 自動產生的 Domain Code,對於 FOREIGN KEY 會以 annotation: @ManyToMany(fetch = FetchType.LAZY) 來作註,但執行時會發生下列的錯誤
Struts Problem Report
Struts has detected an unhandled exception:
- failed to lazily initialize a collection of role: com.mis.model.Admin.roles, could not initialize proxy - no Session
Stacktraces
- 5月 04 週四 201708:54
JPA Error Code: java.lang.NoSuchMethodError: javax.persistence.Table.indexes()[Ljavax/persistence/Index;
作法如下:
If you are using Jboss 7.1.1, jboss already has hibernate-jpa-2.0 in its classpath, so during runtime it uses the one in its classpath, not the one you've deployed with your app , to point jboss to the hibernate-jpa-2.1 do the following:
-
copy
hibernate-jpa-2.1-api-1.0.0.final.jarto the following directory :jboss-as-7.1.1.Final/modules/javax/persistence/api/main -
open
module.xmland change the resource-root as follows :resource-root path="hibernate-jpa-2.1-api-1.0.0.final.jar"(pointing it to jpa 2.1) -
re-compile and re-deploy your app, then you are good to go.
module.xml 檔案內容, 置換成 hibernate-jpa-2.1-api-1.0.0.Final.jar :
- 3月 10 週五 201711:08
Setup and Configuration of FreeRadius + MySql on Windows 7
所需軟體
1. OS: windows 7
2. xampp-portable-win32-5.5.38-3-VC11.zip
3. FreeRADIUS.net-1.1.7-r0.0.2.exe - 6.74 MB - Licence: GNU/LGPL
4. NTRadPing 測試工具
- 2月 16 週四 201717:15
JBoss EAP 6.4 設定連結 SQL Server 2016 Express
在目錄 %JBOSS_HOME%\modules\com\microsoft\sqlserver\jdbc\main 下放入 module.xml & sqljdbc42.jar。
module.xml 的內容
