Tuesday, August 6, 2013

Override JPA persistence unit properties in code with Google Guice

To override properties from persistence.xml through code while using it with Google guice. One can read the properties from different source and add those properties while installing JpaPersistModule. Following is the sample


1:  Properties persistenceUnit = new Properties();  
2:  persistenceUnit.put("javax.persistence.jdbc.url", "jdbc:mysql://192.168.9.102/MyDB");  
3:  persistenceUnit.put("javax.persistence.jdbc.user", "myuser");  
4:  persistenceUnit.put("javax.persistence.jdbc.password", "mypassword");  
5:  Injector injector = Guice.createInjector(new JpaPersistModule("my-persistence-unit").properties(persistenceUnit));  


One can chose to read this configuration from some other file and install JpaPersistModule with those properties. This could be useful to override database url for test and production.

138 comments:

  1. Hibernate Online Training Hibernate Online Training Hibernate Training in Chennai Hibernate Training in Chennai Java Online Training Java Online Training Hibernate Training Institutes in ChennaiHibernate Training Institutes in Chennai

    Java Training Institutes Java Training Institutes
    Java Spring Hibernate Training Institutes in Chennai J2EE Training Institutes in Chennai J2EE Training Institutes in Chennai Core Java Training Institutes in Chennai Core Java Training Institutes in Chennai

    ReplyDelete
  2. Hibernate is an ORM (Object-Relational Mapping) system which is information to get to layer which can be combined with spring and struts.Thanks for sharing this useful post.
    Regards,
    Hibernate Training in Chennai | Hibernate course in Chennai | Spring and Hibernate Training in Chennai

    ReplyDelete
  3. Excellent post. I have read your blog it's very interesting and informative. Keep sharing.
    erp software in chennai

    ReplyDelete
  4. thank you for such a great article with us. hope it will be much useful for us. please keep on updating..
    Web D School

    ReplyDelete
  5. Nice Blog.Thank you for Sharing. I'm working in brave technologies private limited.we are leading cloud erp software solution in chennai

    ReplyDelete
  6. First up all we need to create for a persistence.XML folder file and put the name for META-INF and root login for and save classpath.if you’re using Maven you can create src/main/java/META-INF/persistence.xml.I also define JPA properties later on in the tutorial when creating the EntityManagerFactory.If want become learn for Hadoop Training with Java code using MapReduce concepts and learn Big Data knowledge to real-time projects reach us Besant Technologies.To click the training details,Hadoop Training in Chennai | Hadoop Training Institute in Chennai

    ReplyDelete
  7. The best thing is that your blog really informative thanks for your great information! I have got some important suggestions from it.
    Best Embedded Systems Training in Chennai | C & C++ Training Institute in Chennai | No.1 Embedded Training in Chennai

    ReplyDelete
  8. The Spring Framework is a lightweight framework for developing Java enterprise applications. It provides high performing, easily testable and reusable code. Spring handles the infrastructure as the underlying framework so that you can focus on your application.Spring is modular in design, thereby making creation, handling and linking of individual components so much easier. Spring implements Model View Container(MVC) design pattern.
    spring mvc form example

    ReplyDelete
  9. Really it was an awesome article...very interesting to read..You have provided an nice article....Thanks for sharing..
    Android Training in Chennai
    Ios Training in Chennai

    ReplyDelete
  10. Great Article… I love to read your articles because your writing style is too good, its is very very helpful us...Android Projects Center in Chennai | Android Projects Center in Velachery

    ReplyDelete
  11. Excellent post. I have read your blog it's very interesting and informative. Keep sharing.
    Image Processing Project Center in Chennai | Image Processing Project Center in Velachery

    ReplyDelete
  12. Awesome Blog with informative concept. Really I feel happy to see this useful blog, Thanks for sharing such a great blog. Software Testing Training Institute in Chennai | Selenium Training Institute in Chennai | ISTQB Training Institute in Chennai

    ReplyDelete
  13. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me.Robotics Project Center in Chennai | IEEE Robotics Project Center in Chennai

    ReplyDelete
  14. Simple and clear post on JPA persistence. The content is unique and easily understandable. Thanks for sharing and keep updating.
    Final Year Project Center in Chennai | IEEE Project Center in Chennai | Diploma Project Center in Chennai

    ReplyDelete
  15. This comment has been removed by the author.

    ReplyDelete
  16. This blog is really useful and it is very interesting thanks for sharing , it is really good and exclusive.
    Final Year Project Center in Chennai | Final Year Project Center in Velachery

    ReplyDelete
  17. Your Blog is nice and informative with smart and cute content..keep sharing such an excellent post.
    No.1 Mobile Computing Project Center in Chennai | Best Mobile Computing Projects in Velachery

    ReplyDelete
  18. Your new valuable key points imply much a person like me and extremely more to my office workers. With thanks; from every one of us.


    white label website builder

    mobile website builder

    ReplyDelete
  19. It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me

    digital marketing training in chennai

    ReplyDelete
  20. looks lovely on you, but I’m scared of pink eye shadow Like you said, the crying zombie look is not what I’m going for!Emi at Project Swatch recently posted … Perfect Graphics Designing Training Institute in Chennai | Best CorelDraw Training Institute in Velachery

    ReplyDelete
  21. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging…
    Best Selenium Training Institute in Chennai | Selenium Training Institute in Velachery

    ReplyDelete
  22. Great information. I have got some important suggestions from it. Thank you for sharing.

    Best VMware Training Institute in Chennai | Best VMware Training Institute in Velachery

    ReplyDelete
  23. The young boys ended up stimulated to read through them and now have unquestionably been having fun with these things.

    Best Java Training Institute Chennai

    ReplyDelete
  24. Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
    Hadoop Training Institute In chennai

    ReplyDelete
  25. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
    Best selenium training Institute in chennai

    ReplyDelete
  26. Useful information and kindly keep update such a nice blog. Thanks for sharing... Tata Sky | Tata Sky New Connection | Tata Sky DTH New Connection

    ReplyDelete
  27. Really it was an awesome article... very interesting to read..You have provided an nice article... Thanks for sharing... Tata Sky | Tata Sky New Connection | Tata Sky DTH New Connection

    ReplyDelete
  28. My rather long internet look up has at the end of the day been compensated with pleasant insight to talk about with my family and friends.
    VMware Exam Centers in Chennai | VMware Exam Centers in Velachery

    ReplyDelete
  29. Impressive blog with lovely information. really very useful article for us thanks for sharing such a wonderful blog... 
    ISTQB Certification Training in Chennai | Java Exam Center in Chennai | Microsoft Dot net Certification in Chennai

    ReplyDelete
  30. Wonderful post. I am learning so many things from your blog..keep posting.
    OCJP Exam Center in Chennai | OCJP Exam Center in Velachery

    ReplyDelete
  31. I really enjoy simply reading all of your weblogs. Simply wanted to inform you that you have people like me who appreciate your work. 
    ISTQB Certification Training in Chennai | Java Exam Center in Chennai | Microsoft Dot net Certification in Chennai

    ReplyDelete
  32. It was so good to read and useful to improve my knowledge as updated one.Thanks to sharing.
    OCJP Exam Center in Chennai | OCJP Exam Center in Velachery

    ReplyDelete
  33. Useful information and kindly keep update such a nice blog. Thanks for sharing...
    Citrix Exams in Chennai | Xenapp exam center in Chennai

    ReplyDelete
  34. Thanks for splitting your comprehension with us. It’s really useful to me & I hope it helps the people who in need of this vital information. InDesign Certification Training in Chennai | No.1 InDesign Course in Saidapet

    ReplyDelete
  35. I believe that there will be very good opportunities for the people who are coming around this area.
    Citrix Exams in Chennai | Xenapp exam center in Chennai

    ReplyDelete
  36. I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
    OCJP Exam Center in Chennai | OCJP Exam Center in Velachery

    ReplyDelete
  37. Appreciation for really being thoughtful and also for deciding on certain marvelous guides most people really want to be aware of.
    VMware Exam Centers in Chennai | VMware Exam Centers in Velachery

    ReplyDelete
  38. Appreciation for really being thoughtful and also for deciding on certain marvelous guides most people really want to be aware of.
    Citrix Exams in Chennai | Xenapp exam center in Chennai

    ReplyDelete
  39. Enjoyed reading the article above , really explains everything in detail,the article is very interesting and effective.Thank you and good luck...
    Best RPA Training Institute in Chennai | Best RPA Training Institute in Velachery

    ReplyDelete
  40. Appreciation for really being thoughtful and also for deciding on certain marvelous guides most people really want to be aware of.
    No.1 Automation Anywhere Training Institute in Chennai | No.1 Automation Anywhere Training Institute in Velachery

    ReplyDelete
  41. Hi, am a big follower of your blog. I am really happy to found such a helpful and fascinating post that is written in well manner. Thanks for sharing such an informative post. keep update your blog.
    RPA Training Course in Chennai | RPA Training Course in Velachery

    ReplyDelete
  42. Hi, am a big follower of your blog. I am really happy to found such a helpful and fascinating post that is written in well manner. Thanks for sharing such an informative post. keep update your blog.
    Blue Prism Robotic Process Automation in Chennai | Blue Prism Robotic Process Automation in Velachery

    ReplyDelete
  43. Extremely exceptionally educational post you shared here. Continue sharing this sort of useful blog.
    Graphic Designing Training Institute in Chennai | UIPath Certification Training in Chennai

    ReplyDelete
  44. I really enjoy simply reading all of your weblogs. Simply wanted to inform you that you have people like me who appreciate your work.
    ISTQB Certifications Exams Course in Chennai | QA Testing in Meenambakkam

    ReplyDelete
  45. I believe that there will be very good opportunities for the people who are coming around this area.
    Certified Ethical Hacking Training in Chennai | Blue Prism Training Institute in Chennai

    ReplyDelete
  46. Amazing Article, thank you!. I am very glad to read your informative & practical blog. Kindly keep updating your blog.
    CLOUD COMPUTING Classes in Chennai | CLOUD COMPUTING Courses in Velachery

    ReplyDelete
  47. Thanks for one marvelous posting! I enjoyed reading it; you are a great author. I will make sure to bookmark your blog and may come back someday. I want to encourage that you continue your great posts, have a nice weekend!
    No.1 Blue Prism Training Institute in Chennai | No.1 Blue Prism Training Institute in Velachery | No.1 Blue Prism Training Institute in Kanchipuram

    ReplyDelete
  48. I was curious if you ever considered changing the layout of your site? It’s very well written; I love what you’ve got to say. You’ve got an awful lot of text.
    Automation Anywhere Training with Placement in Chennai | Automation Anywhere Training with Placement in Tambaram

    ReplyDelete
  49. Appreciation for really being thoughtful and also for deciding on certain marvelous guides most people really want to be aware of.
    JAVA and J2EE Training Institute in Chennai | JAVA and J2EE Training Institute in Velachery

    ReplyDelete
  50. Thanks for one marvelous posting! I enjoyed reading it; you are a great author. I will make sure to bookmark your blog and may come back someday. I want to encourage that you continue your great posts, have a nice weekend!
    No.1 Automation Anywhere Training Institute in Chennai | No.1 Automation Anywhere Training Institute in Velachery

    ReplyDelete
  51. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging…
    Best Selenium Training Institute in Chennai|Best Selenium Training Institute in Medavakkam

    ReplyDelete
  52. Thanks for this grateful information. all this information is very important to all the users and can be used good at all this process.
    Python Certification Course in Chennai | Python Certification Course in OMR

    ReplyDelete
  53. Thanks for your good post.This social marketing plan is really helpful for all business personalities.This article is really interesting.keep on updating on us in this.
    Blue Prism Robotic Process Automation in Chennai | Blue Prism Robotic Process Automation in Chennai

    ReplyDelete
  54. Nice Blog… Wonderful Information and really very much useful. Thanks for sharing and keep updating…
    Python Training Institute in Chennai | Python Training Institute in Velachery

    ReplyDelete
  55. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge.
    Hardware and Networking Training in Chennai | Hardware and Networking Training in Taramani

    ReplyDelete
  56. Hello. This post couldn’t be written any better! Reading this post reminds me of my previous roommate. He always kept chatting about this. I will forward this page to him. Fairly certain he will have a good read. Thank you for sharing.
    Python Exam Centers in Chennai | Python Exam Centers in Chennai

    ReplyDelete
  57. The provided information’s are very useful to me.Thanks for sharing.Keep updating your blog.
    C and C++ Training in Chennai | C and C++ Training in Taramani

    ReplyDelete
  58. Impressive blog with lovely information. Really very useful article for us thanks for sharing such a wonderful blog...
    MCSE&MCSA Training institute in Chennai |MCSE&MCSA Training institute in Madipakkam

    ReplyDelete
  59. Really it was an awesome blog...... Very interesting to read, .It’s very helpful for me, Big thanks for the useful info and keep updating…
    CCNP Training Institute in Chennai | CCNP Training Institute in Velachery

    ReplyDelete
  60. Very informative blog. Thanks for sharing such good information and keep on updating.
    Oracle Training in Chennai | Oracle Training in Kanchipuram

    ReplyDelete
  61. It's interesting that many of the bloggers to helped clarify a few things for me as well as giving. Most of ideas can be nice content.
    Software Testing Training Institute in Chennai |Software Testing Training Institute in Taramani

    ReplyDelete
  62. Your Blog is really amazing with useful information you are shared here...Thank you for sharing such an informative and awesome post with us. Keep blogging article like this……..
    AWS Training Institute in Chennai | AWS Training Institute in Velachery

    ReplyDelete
  63. Hello there! This is my first comment here, so I just wanted to give a quick shout out and say I genuinely enjoy reading your articles. Thanks.
    Blueprism Exam Center in Chennai | Blueprism Exam Center in Velachery

    ReplyDelete
  64. Really I enjoy this blog….. Very nice post… Thanks for sharing and keep updating
    AWS Training Institute in Chennai | AWS Training Institute in Velachery

    ReplyDelete
  65. This is a nice post in an interesting line of content.Thanks for sharing this article.
    Best UIPath Training Institute in Chennai | Best UIPath Training Institute in Velachery

    ReplyDelete
  66. Thank you so much for sharing such an amazing post with useful information with us. Keep updating such a wonderful blog….
    Best CCNA Training Institute in Chennai| CCNA Training Center in Velachery

    ReplyDelete
  67. It's very great post... Really you are... done a wonderful job Keep up the good work and continue sharing like this.
    Ethical Hacking Training Course in Chennai | Ethical Hacking Training Course in Nanganallur

    ReplyDelete
  68. Thank you so much for sharing this worth able content with us. Keep blogging article like this.
    Best Selenium Training Institute in Chennai|Best Selenium Training Institute in Saidapet

    ReplyDelete
  69. Nice blog…. with lovely information. Really very useful article for us thanks for sharing such a wonderful blog. Keep updating…..
    Best Linux Training Institute in Pallikaranai| Best Linux Training Institute in Velachery

    ReplyDelete
  70. Awesome article…. Really very helpful information for us. Keep it up. Keep blogging. Looking to reading your next post,. Thank You for Sharing This Information
    Best PCB Training Institute in Taramani| Best PCB Training Institute in Velachery

    ReplyDelete
  71. Good Post…. Thanks for the useful information it’s very useful to read your blog. Keep blogging article like this.
    Best JAVA/J2EE Training Institute in Perungudi| Best JAVA/J2EE Training Institute in Velachery

    ReplyDelete
  72. Nice blog, really I feel happy to see this useful blog… Thanks for sharing this valuable information to our vision....
    Best AWS Training Institute in Medavakkam| Best AWS Training Institute in Velachery

    ReplyDelete
  73. Great post. Wonderful information and really very much useful. Thanks for sharing and keep updating.
    Blue prism Training in Chennai | Blue prism Training in Besant Nagar

    ReplyDelete
  74. Really wonderful post.... My sincere thanks for sharing very useful information to the users... Please continue to share this kind of post
    Best Python Exams Center in OMR| Best Python Certification Exams in OMR

    ReplyDelete
  75. Thank you so much for sharing such an amazing post with useful information with us. Keep updating such a wonderful blog….
    Automation Anywhere Training in Chennai | Automation Anywhere Training in Ashok Nagar

    ReplyDelete
  76. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging…
    Perfect and Outstanding Dotnet Training Institute in Chennai| Perfect and Outstanding Dotnet Training Institute in Adyar

    ReplyDelete
  77. I have read your blog its very attractive and impressive. I like it your blog...
    Graphic Designing Training in Chennai | Graphic Designing Training in Keelkattalai

    ReplyDelete
  78. Wonderful blog… You provided very interesting information here. I feel happy to read this post. I hope that you will write many posts like this… Thanks for sharing and Keep updating…..
    Python Training Institute in Chennai | Python Training Institute in Velachery

    ReplyDelete
  79. Wonderful blog… You provided very interesting information here. I feel happy to read this post. I hope that you will write many posts like this… Thanks for sharing and Keep updating…..
    Python Training Institute in Chennai | Python Training Institute in Velachery

    ReplyDelete
  80. Impressive blog with lovely information. Really very useful article for us thanks for sharing such a wonderful blog...
    Best Selenium Training Institute in Chennai |Best Selenium Training Institute in Chennai

    ReplyDelete
  81. Very useful and information content has been shared out here, Thanks for sharing it.
    Visit Learn Digital Academy for more information on Digital marketing course in Bangalore.

    ReplyDelete
  82. Hello! This is my first visit to your blog! We are a team of volunteers and starting a new initiative in a community in the same niche. Your blog provided us useful information to work on. You have done an outstanding job.
    UIPath Training in Chennai | UIPath Training in Kanchipuram

    ReplyDelete
  83. I have read your blog its very attractive and impressive. I like it your blog...
    Ethical Hacking Training in Chennai | Ethical Hacking Training in Thiruvanmiyur

    ReplyDelete
  84. I have read your blog its very attractive and impressive. I like it your blog.
    Android Training in Chennai | Android Training in Porur

    ReplyDelete
  85. Awesome article…. Really very helpful information for us. Keep it up. Keep blogging. Looking to reading your next post,. Thank You for Sharing This Information
    RPA Training in Chennai | RPA Training in Pallavaram

    ReplyDelete
  86. Nice blog.. Thanks for sharing informative blog.. its very useful to me..
    Java Training in Chennai | Java Training in St.Thomas Mount

    ReplyDelete
  87. This blog is informative. It is really helpful and very unique information is given. thanks for posting this information
    Ethical Hacking Training in Chennai | Ethical Hacking Training in Kanchipuram

    ReplyDelete
  88. Good Post…. Thanks for the useful information it’s very useful to read your blog. Keep blogging article like this.
    Blue prism Training in Chennai | Blue prism Training in Medavakkam

    ReplyDelete
  89. Excellent information with unique content and it is very useful to know about the information based on blogs...
    Software Testing Course in Chennai | Software Testing Course in Perungudi

    ReplyDelete
  90. Your Blog is really awesome with useful and helpful content for us.Thanks for sharing ..keep updating more information.
    Best Ethical Hacking Training Institute in Chennai | Best Ethical Hacking Training Institute in Velachery

    ReplyDelete
  91. Very good and informative article. Thanks for sharing such nice article, keep on updating such good articles.
    JAVA and J2EE Training Institute in Chennai | JAVA and J2EE Training Institute in Besant Nagar

    ReplyDelete
  92. Very interesting content which helps me to get the in depth knowledge about the technology.
    Software Testing Course in Chennai | Software Testing Course in Keelkattalai

    ReplyDelete
  93. Really it was an awesome article. Very useful & Informative..Thanks for sharing..
    IOS Training Institute in Chennai | IOS Training Institute in Pallavaram

    ReplyDelete
  94. Hello there! This is my first comment here, so I just wanted to give a quick shout out and say I genuinely enjoy reading your articles. Thanks.
    No.1 Blue Prism Training Institute in Chennai | No.1 Blue Prism Training Institute in Velachery

    ReplyDelete
  95. Nice and good article. It is very useful for me to learn and understand easily. Thanks for sharing your valuable information and time. Please keep updating...
    Selenium Automation Course in Chennai | Selenium Automation Course in Pallikaranai

    ReplyDelete
  96. Really great post, Thank you for sharing This knowledge.Excellently written article, if only all bloggers offered the same level of content as you, the internet would be a much better place. Please keep it up!
    Automation Anywhere Certification in Chennai | Automation Anywhere Training in Pallikaranai

    ReplyDelete
  97. Amazing news. Thanks for this blog. Very good knowledge and very good information. Simplest method to do this process. This is very useful for many peoples.
    RPA Training in Chennai | RPA Training in Madipakkam

    ReplyDelete
  98. Thanks for sharing this unique information with us.
    - Learn Digital Academy

    ReplyDelete