2014-04-29 4 views
5

मैं यहाँवसंत बूट में हाइबरनेट आंकड़े काम नहीं कर रहे हैं?

https://github.com/jimbasilio/SpringBoot 

एक छोटा सा नमूना अनुप्रयोग है कि डेटाबेस में कुछ सरल डेटा और कुछ अन्य बातों मैं वसंत बूट पर टायर किक करने पर काम कर रहा हूँ बनाता है (ओर टिप्पणी है: अब तक मैं वसंत बूट पसंद !!)। आप Git रेपो क्लोन यदि आप URL पर जाएँ कर सकते हैं:

http://127.0.0.1:8080/hello/get/1 

और यह डेटाबेस से लोड करता हूँ और कंसोल के लिए हाइबरनेट आँकड़े लिखें।

मैं हालांकि एक समस्या है, के साथ या application.properties फ़ाइल के माध्यम से हाइबरनेट आंकड़े को विन्यस्त बिना:

hibernate.generate_statistics=true 

जब मैं हाइबरनेट आंकड़े को लिखने मैं उपयोगी कुछ भी नहीं मिलता है। मैं आंकड़ों को प्राप्त कर रहा हूं:

Session session = (Session) this.entityManager.getDelegate(); 
session.getSessionFactory().getStatistics().logSummary(); 
HelloEntity entity = helloRepository.findOne(id); 
entityManager.flush(); 
session.getSessionFactory().getStatistics().logSummary(); 

मेरा दूसरा लॉग संदेश (फ्लश के बाद) नीचे है। आप देख सकते हैं कि यह खोले जाने वाले सत्र भी पंजीकृत नहीं करता है। मैं वसंत बूट 1.0.1.RELEASE का उपयोग कर रहा हूँ।

pom.xml

<parent> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-parent</artifactId> 
    <version>1.0.1.RELEASE</version> 
</parent> 

लॉग फ़ाइल:

2014-04-28 20:51:29.415 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000161: Logging statistics.... 
2014-04-28 20:51:29.416 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000251: Start time: 1398732682476 
2014-04-28 20:51:29.416 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000242: Sessions opened: 0 
2014-04-28 20:51:29.416 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000241: Sessions closed: 0 
2014-04-28 20:51:29.416 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000266: Transactions: 0 
2014-04-28 20:51:29.416 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000258: Successful transactions: 0 
2014-04-28 20:51:29.417 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000187: Optimistic lock failures: 0 
2014-04-28 20:51:29.417 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000105: Flushes: 0 
2014-04-28 20:51:29.417 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000048: Connections obtained: 0 
2014-04-28 20:51:29.417 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000253: Statements prepared: 0 
2014-04-28 20:51:29.417 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000252: Statements closed: 0 
2014-04-28 20:51:29.417 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000239: Second level cache puts: 0 
2014-04-28 20:51:29.418 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000237: Second level cache hits: 0 
2014-04-28 20:51:29.418 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000238: Second level cache misses: 0 
2014-04-28 20:51:29.418 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000079: Entities loaded: 0 
2014-04-28 20:51:29.418 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000080: Entities updated: 0 
2014-04-28 20:51:29.418 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000078: Entities inserted: 0 
2014-04-28 20:51:29.418 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000076: Entities deleted: 0 
2014-04-28 20:51:29.419 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000077: Entities fetched (minimize this): 0 
2014-04-28 20:51:29.419 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000033: Collections loaded: 0 
2014-04-28 20:51:29.419 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000036: Collections updated: 0 
2014-04-28 20:51:29.419 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000035: Collections removed: 0 
2014-04-28 20:51:29.419 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000034: Collections recreated: 0 
2014-04-28 20:51:29.420 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000032: Collections fetched (minimize this): 0 
2014-04-28 20:51:29.420 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000438: NaturalId cache puts: 0 
2014-04-28 20:51:29.420 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000439: NaturalId cache hits: 0 
2014-04-28 20:51:29.420 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000440: NaturalId cache misses: 0 
2014-04-28 20:51:29.420 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000441: Max NaturalId query time: 0ms 
2014-04-28 20:51:29.420 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000442: NaturalId queries executed to database: 0 
2014-04-28 20:51:29.420 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000210: Queries executed to database: 0 
2014-04-28 20:51:29.420 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000215: Query cache puts: 0 
2014-04-28 20:51:29.421 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000433: update timestamps cache puts: 0 
2014-04-28 20:51:29.421 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000434: update timestamps cache hits: 0 
2014-04-28 20:51:29.421 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000435: update timestamps cache misses: 0 
2014-04-28 20:51:29.421 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000213: Query cache hits: 0 
2014-04-28 20:51:29.421 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000214: Query cache misses: 0 
2014-04-28 20:51:29.421 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000173: Max query time: 0ms 

उत्तर

2

मुझे लगता है कि हाइबरनेट सिर्फ अपने config पढ़ने नहीं है।

Hibernate's Reference Manual के अनुसार आपको hibernate.properties या hibernate.cfg.xml पर हाइबरनेट कॉन्फ़िगरेशन रखना होगा। अगर वे काम नहीं करते हैं तो आप प्रोग्रामैटिक कॉन्फ़िगरेशन को भी आजमा सकते हैं।

+0

कि यह बजाय-!! मैं चौंकाने वाला हूँ। मैंने सोचा कि सभी गुण एक साथ विलय कर दिए गए थे। आपके उत्तर के लिए धन्यवाद! – JimB

+2

पता चला है कि आप देशी जेपीए प्रदाता के लिए सेटिंग्स को उपसर्ग कर सकते हैं और उन्हें application.properties में रख सकते हैं, मुझे वसंत बूट डॉक्स में यह याद आया। इसलिए मेरे मामले में मैंने जोड़ा: spring.jpa.properties.hibernate.generate_statistics = मेरे application.properties फ़ाइल के लिए सच है और चीजें भी काम करती हैं। मैं इसे hibernate.properties फ़ाइल में पसंद करता हूं क्योंकि मैं dev- test/prod सेटिंग्स के लिए एप्लिकेशन- {profile} .properties के साथ ओवरराइड कर सकता हूं। किक के लिए फिर से धन्यवाद, यह मदद की। – JimB

20

उपयोग spring.jpa.properties.hibernate.generate_statistics=true
hibernate.generate_statistics=true

+1

यह सही तरीका है जिसका मतलब है कि "वसंत बूट" इसे करने का तरीका है। – destan

संबंधित मुद्दे