Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
ලංකාවේ හොඳම උපකාරක පන්ති සහ ගුරුවරුන් එකම තැනකින් - TopTuition.lk
dulithapathum
Updated:
Yesterday at 8:07 AM
Colombo
RidhMathraa ’26 🎶✨
Tmadhusanka
Updated:
Wednesday at 11:58 PM
Ad icon
Colombo
PXN V10 Pro Direct Drive Racing Wheel (Under Warranty)
Abdur Rahman
Updated:
Wednesday at 10:23 PM
Ad icon
USDT ණය සේවාව - USDT Loan Service
පුරවැසියා
Updated:
Wednesday at 4:54 PM
Ad icon
🎮 INDIAN PSN GIFT CARDS AVAILABLE NOW! 🎮
madukaperera
Updated:
Tuesday at 12:57 PM
Electronics
Vehicles
Property
Search
Reply to thread
Forums
Computers & Internet
Software Development
java web development 9 කොටස - Hibernate with annotations
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="J Sparrow" data-source="post: 19548204" data-attributes="member: 387729"><p><span style="font-size: 18px">හා හා! දැං තියෙන වැඩ පැත්තකින් දාලා වරෙව්!</span></p><p><span style="font-size: 18px"></span></p><p><span style="font-size: 18px">STS open කරගෙන, MySQL open කරගෙන, database connection හදාගෙන ලෑස්ති වෙයව්! <img src="/styles/default/xenforo/smilies/default/angry.gif" class="smilie" loading="lazy" alt=":angry:" title="Angry :angry:" data-shortname=":angry:" /><img src="/styles/default/xenforo/smilies/default/angry.gif" class="smilie" loading="lazy" alt=":angry:" title="Angry :angry:" data-shortname=":angry:" /><img src="/styles/default/xenforo/smilies/default/angry.gif" class="smilie" loading="lazy" alt=":angry:" title="Angry :angry:" data-shortname=":angry:" /></span></p><p><span style="font-size: 18px"></span></p><p><span style="font-size: 18px">හොඳායි....</span></p><p><span style="font-size: 18px"></span></p><p><span style="font-size: 18px">අද අපිට කරන්න තියෙන්නේ, Annotations use කරලා Hibernate වලින් කොහොමද Database එකට කොක්කක් ගහගන්නේ කියලා හොයලා බලන්න. <img src="/styles/default/xenforo/smilies/default/rolleyes.gif" class="smilie" loading="lazy" alt=":rolleyes:" title="Rolleyes :rolleyes:" data-shortname=":rolleyes:" /></span></p><p><span style="font-size: 18px"></span></p><p><span style="font-size: 18px">Annotation එකක් කියන්නේ මොකද්ද කියලා කට්ටිය දන්නවා ඇති කියලා හිතනවා.</span></p><p><span style="font-size: 18px"></span></p><p><span style="font-size: 18px"><img src="http://i.imgur.com/O8uGm9H.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /></span></p><p><span style="font-size: 18px"></span></p><p><span style="font-size: 18px">ඔය නිල් පාටින් කොටු කරලා තියෙන්නේ Annotations . පොඩි හරි idea එකක් ගන්න පුළුවන්නේ? කොහොමද මේක use වෙන්නේ කියලා?</span></p><p><span style="font-size: 18px"></span></p><p><span style="font-size: 18px">මේකට අපි කලින් හදපු project එකම use කරනවා මම. බොලාලට ඉතිං කැමැත්තක් කොරන්ඩ පුලුවනි! අළුතෙන්ම එකක් හදනවානම් තමයි ඉතිං හොඳ. <img src="/styles/default/xenforo/smilies/default/yes.gif" class="smilie" loading="lazy" alt=":yes:" title="Yes :yes:" data-shortname=":yes:" /></span></p><p><span style="font-size: 18px"></span></p><p><span style="font-size: 18px">ඔන්න වැඩේට බැස්සා! <img src="/styles/default/xenforo/smilies/default/cool.gif" class="smilie" loading="lazy" alt=":cool:" title="Cool :cool:" data-shortname=":cool:" /></span></p><p><span style="font-size: 18px"></span></p><p><span style="font-size: 18px">චූටි චූටි වෙනස්කම් කීපයයි කරන්න තියෙන්නේ. <img src="/styles/default/xenforo/smilies/default/D.gif" class="smilie" loading="lazy" alt=":D" title="Big grin :D" data-shortname=":D" /></span></p><p><span style="font-size: 18px"></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><strong>1 - Add Hibernate annotation dependency.</strong></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue">කලින් පාවිච්චි කරපු dependencies වලට අමතරව අපිට තව මේ dependency දෙකත් add කරගන්න වෙනවා!</span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"></span></span></p><p> <span style="font-size: 18px"><span style="color: DarkSlateBlue">i - hibernate-annotations --> 3.3.0.GA</span></span></p><p> <span style="font-size: 18px"><span style="color: DarkSlateBlue">ii - hibernate-commons-annotations --> 3.3.0.GA</span></span></p><p> <span style="font-size: 18px"><span style="color: DarkSlateBlue"></span></span></p><p> <span style="font-size: 18px"><span style="color: DarkSlateBlue">ඔය? පේනවනේ?</span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><img src="http://i.imgur.com/J7ncn0f.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue">ඔන්න මම add කරගත්තා.</span></span></p><p> <span style="font-size: 18px"><span style="color: DarkSlateBlue"></span></span></p><p> <span style="font-size: 18px"><span style="color: DarkSlateBlue"><strong><span style="color: Navy">2 - Update HibernateUtil.java</span></strong></span></span></p><p> <span style="font-size: 18px"><span style="color: DarkSlateBlue"></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Navy"> මතකයිනේ? එදා අපි හදා ගත්තා HibernateUtil කියලා class එකක්?</span></span></span></p><p> <span style="font-size: 18px"><span style="color: DarkSlateBlue"></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><img src="http://i.imgur.com/Rpzsk7M.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /></span></span></p><p> <span style="font-size: 18px"><span style="color: DarkSlateBlue"></span></span></p><p> <span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Navy">ඔව් ඔව්! ඔය තියෙන්නේ... <img src="/styles/default/xenforo/smilies/default/wink.gif" class="smilie" loading="lazy" alt=";)" title="Wink ;)" data-shortname=";)" /></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Navy"></span></span></span></p><p> <span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Navy">ඒක open කරලා line number වලට 13 ට ගිහිල්ලා බැලුවාම උඹලට මෙන්න මෙහෙම code කෑල්ලක් පේන්න ඕනේ.</span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Navy"></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Navy"></span> <span style="font-size: 15px"><span style="color: DarkSlateGray">return new Configuration().configure().buildSessionFactory();</span></span></span></span></p><p> <span style="font-size: 18px"><span style="color: DarkSlateBlue"></span></span></p><p> <span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Navy">තියෙනවා?</span></span></span></p><p> <span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Navy"></span></span></span></p><p> <span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Navy">then good!</span></span></span></p><p> <span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Navy"></span></span></span></p><p> <span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Navy">Folks, අපි දැන් ඒක replace කරගන්න යන්නේ!</span></span></span></p><p> <span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Navy"></span></span></span></p><p> <span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Navy">මෙන්න මේ code කෑල්ලෙන්!</span></span></span></p><p> <span style="font-size: 18px"><span style="color: DarkSlateBlue"></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"> <span style="color: DarkSlateGray">return new AnnotationConfiguration().configure().buildSessionFactory();</span></span></span></span></p><p> <span style="font-size: 18px"><span style="color: DarkSlateBlue"></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Navy">වෙනස බලාපල්ලා, කලින් code එක out of fashion . ඒක තිබ්බේ xml use කරලා configure කරන්න!</span></span></span></p><p> <span style="font-size: 18px"><span style="color: DarkSlateBlue"></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Navy">දැං code එක තියෙන්නේ, Annotation use කරලා configure කරන්න!</span></span></span></p><p> <span style="font-size: 18px"><span style="color: DarkSlateBlue"></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: DarkRed"><strong>3 - Update Model class</strong></span></span></span></p><p> <span style="font-size: 18px"><span style="color: DarkSlateBlue"></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: DarkRed">මතකයිනේ? අපි එදා අපේ modal class එක හැදුවා Stock කියලා? ආන්න ඒකත් edit කරගන්න ඕනේ. </span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: DarkRed"></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: DarkRed">මෙන්න මේ Stock class එක (modal class එක) ට තමයි අපි annotations දාගන්නේ!</span></span></span></p><p> <span style="font-size: 18px"><span style="color: DarkSlateBlue"></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: DarkRed">හරි! මෙන්න මෙහෙමයි edit වෙන්නේ.</span></span></span></p><p> <span style="font-size: 18px"><span style="color: DarkSlateBlue"></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray">package com.inventory.common;</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"></span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray">import javax.persistence.Column;</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray">import javax.persistence.Entity;</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray">import javax.persistence.GeneratedValue;</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray">import static javax.persistence.GenerationType.IDENTITY;</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray">import javax.persistence.Id;</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray">import javax.persistence.Table;</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray">import javax.persistence.UniqueConstraint;</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"></span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray">@Entity</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray">@Table(name = "stock", catalog = "inventory", uniqueConstraints = {</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> @UniqueConstraint(columnNames = "STOCK_NAME"),</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> @UniqueConstraint(columnNames = "STOCK_CODE") })</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray">public class Stock implements java.io.Serializable {</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"></span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> private Integer stockId;</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> private String stockCode;</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> private String stockName;</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"></span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> public Stock() {</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> }</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"></span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> public Stock(String stockCode, String stockName) {</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> this.stockCode = stockCode;</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> this.stockName = stockName;</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> }</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"></span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> @Id</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> @GeneratedValue(strategy = IDENTITY)</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> @Column(name = "STOCK_ID", unique = true, nullable = false)</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> public Integer getStockId() {</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> return this.stockId;</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> }</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"></span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> public void setStockId(Integer stockId) {</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> this.stockId = stockId;</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> }</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"></span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> @Column(name = "STOCK_CODE", unique = true, nullable = false, length = 10)</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> public String getStockCode() {</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> return this.stockCode;</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> }</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"></span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> public void setStockCode(String stockCode) {</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> this.stockCode = stockCode;</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> }</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"></span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> @Column(name = "STOCK_NAME", unique = true, nullable = false, length = 20)</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> public String getStockName() {</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> return this.stockName;</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> }</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"></span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> public void setStockName(String stockName) {</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> this.stockName = stockName;</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> }</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray"> </span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="font-size: 15px"><span style="color: DarkSlateGray">}</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><strong><span style="color: Red">** The import javax.persistence cannot be resolved කියලා errors පෙන්නන්න ගත්තොතින් ඔය පහල තියෙන jar එකත් add කරගනිල්ලා.</span></strong></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><strong><span style="color: Red">- බොහෝ දුරට add කරගන්න වෙයි උඹලට.</span></strong></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><strong><span style="color: Red"> </span></strong></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><strong><span style="color: Red"> - ejb3-persistence --> 1.0.2.GA</span></strong></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><strong><span style="color: DarkGreen">4 - Delete existing Hibernate XML mapping file</span></strong></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: DarkGreen"></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: DarkGreen">Stock.hbm.xml file එක මතකයිනේ? ඔව් ඔව්! mapping file එක තමයි බොලව්. ඔන්න ඔය "හු" යන්න delete කරපියව්! තව දුරටත් ඕකෙන් වැඩක් වෙන්නේ නෑ</span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><strong><span style="color: DarkOrange"></span></strong></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><strong><span style="color: DarkOrange">5 - Update Hibernate configuration file.</span></strong></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: DarkOrange">දැං Update Hibernate configuration file එක ඔය පහල තියෙන විදියට edit කරගන්න ඕනේ.</span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><img src="http://i.imgur.com/STiRpVR.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: DarkOrange">මෙන්න මේ විදියට තමයි දැං Update Hibernate configuration file එක පේන්න තියෙන්නේ.</span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: DarkOrange"></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><img src="http://i.imgur.com/nQ26xr0.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: DarkOrange">මේ? දැක්කද full project structure එක?</span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><img src="http://i.imgur.com/d2aengt.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: DarkOrange">ඔන්න ඒකත් හරි!</span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><strong><span style="color: DarkOrange"><u>Run කරලා බලන එකයි තියෙන්නේ.</u></span></strong></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><strong><span style="color: DarkOrange"></span></strong></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><strong><span style="color: DarkOrange">App class උඩ right click කලා --> Run as --> Java application</span></strong></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><img src="http://i.imgur.com/L4f1gz2.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Indigo">පේනවනේ? මම අළුත් data ටිකක් දාගෙන තියෙන්නේ save කරගන්න.</span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Indigo"></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Indigo">Here is the result..</span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Indigo"></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><img src="http://i.imgur.com/qc85jgy.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Indigo">ඔය රතු පාටින් තියෙන්නේ මම අළුතෙන් දාපු data ටික</span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Indigo"></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Indigo"><strong>මේ වෙනස සැපයි කියලා හිතනවා උඹලට. </strong></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Indigo"><strong>** එහෙම නැත්තන් උඹලට hbm.xml ලිය ලිය බලු කට්ටක් කන්න වෙන්නේ. දැං වැඩේ ලේසිනේ? Model class එකෙන්ම වැඩේ ගොඩ.</strong></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Indigo"></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Indigo"><span style="color: Black">හරි! ඊළඟට තියෙන්නේ ටිකක් ලොකු පිම්මක් පනින්න. අපි Maven ගැන ඉගෙන ගන්න යන්නේ. </span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Indigo"></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Indigo"><strong><span style="color: Navy">Maven Athapaththu?? <img src="/styles/default/xenforo/smilies/default/rofl.gif" class="smilie" loading="lazy" alt=":rofl:" title="ROFL :rofl:" data-shortname=":rofl:" /><img src="/styles/default/xenforo/smilies/default/rofl.gif" class="smilie" loading="lazy" alt=":rofl:" title="ROFL :rofl:" data-shortname=":rofl:" /><img src="/styles/default/xenforo/smilies/default/rofl.gif" class="smilie" loading="lazy" alt=":rofl:" title="ROFL :rofl:" data-shortname=":rofl:" /></span></strong></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Indigo"><strong><span style="color: Navy"></span></strong></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Indigo"><strong><span style="color: Navy"></span></strong><img src="http://p.imgci.com/db/PICTURES/CMS/194400/194497.4.jpg" alt="" class="fr-fic fr-dii fr-draggable " style="" /></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Indigo"></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Indigo"><span style="color: Black">නෑ නෑ! <img src="/styles/default/xenforo/smilies/default/angry.gif" class="smilie" loading="lazy" alt=":angry:" title="Angry :angry:" data-shortname=":angry:" /><img src="/styles/default/xenforo/smilies/default/angry.gif" class="smilie" loading="lazy" alt=":angry:" title="Angry :angry:" data-shortname=":angry:" /></span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Indigo"><span style="color: Black"></span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Indigo"><span style="color: Black">මේක dependency managment and build automation tool එකක්.</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Indigo"><span style="color: Black"></span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Indigo"><span style="color: Black"><strong>ඒ උනාට Maven Athapaththu වගේම තාක්ෂණයෙන් බොහෝම අනූනයි. <img src="/styles/default/xenforo/smilies/default/yes.gif" class="smilie" loading="lazy" alt=":yes:" title="Yes :yes:" data-shortname=":yes:" /></strong></span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Indigo"><span style="color: Black"></span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Indigo"><span style="color: Black">ඔන්න දැන් අපි ටිකෙන් ටික more advanced technologies use කරන්න පටන් ගන්නවා. <img src="/styles/default/xenforo/smilies/default/cool.gif" class="smilie" loading="lazy" alt=":cool:" title="Cool :cool:" data-shortname=":cool:" /> ඉතිං basic හරියට නැති කට්ටිය basic brush-up කරගෙනම ඊළඟ lessons වලට join උනොත් තමයි හොඳ. <img src="/styles/default/xenforo/smilies/default/wink.gif" class="smilie" loading="lazy" alt=";)" title="Wink ;)" data-shortname=";)" /></span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Indigo"><span style="color: Black"></span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Indigo"><span style="color: Black"><span style="color: #000000"><span style="font-family: 'verdana'">මේකට උඹලගේ කැපවීම අනිවාර්යයි! මට පුලුවන් බොලාට මඟ පෙන්නන්න විතරයි! </span></span><img src="/styles/default/xenforo/smilies/default/yes.gif" class="smilie" loading="lazy" alt=":yes:" title="Yes :yes:" data-shortname=":yes:" /></span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Indigo"><span style="color: Black"></span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Indigo"><span style="color: Black">එහෙනම් හැමෝටම ජය!</span></span></span></span></p><p><span style="font-size: 18px"><span style="color: DarkSlateBlue"><span style="color: Indigo"><span style="color: Black"></span></span></span></span></p><p></p><p><a href="http://www.elakiri.com/forum/tags.php?tag=web+development" target="_blank">කලින් දාපු lessons ටික මෙතනින් බලල go through කරපල්ලා</a></p></blockquote><p></p>
[QUOTE="J Sparrow, post: 19548204, member: 387729"] [SIZE=5]හා හා! දැං තියෙන වැඩ පැත්තකින් දාලා වරෙව්! STS open කරගෙන, MySQL open කරගෙන, database connection හදාගෙන ලෑස්ති වෙයව්! :angry::angry::angry: හොඳායි.... අද අපිට කරන්න තියෙන්නේ, Annotations use කරලා Hibernate වලින් කොහොමද Database එකට කොක්කක් ගහගන්නේ කියලා හොයලා බලන්න. :rolleyes: Annotation එකක් කියන්නේ මොකද්ද කියලා කට්ටිය දන්නවා ඇති කියලා හිතනවා. [IMG]http://i.imgur.com/O8uGm9H.png[/IMG] ඔය නිල් පාටින් කොටු කරලා තියෙන්නේ Annotations . පොඩි හරි idea එකක් ගන්න පුළුවන්නේ? කොහොමද මේක use වෙන්නේ කියලා? මේකට අපි කලින් හදපු project එකම use කරනවා මම. බොලාලට ඉතිං කැමැත්තක් කොරන්ඩ පුලුවනි! අළුතෙන්ම එකක් හදනවානම් තමයි ඉතිං හොඳ. :yes: ඔන්න වැඩේට බැස්සා! :cool: චූටි චූටි වෙනස්කම් කීපයයි කරන්න තියෙන්නේ. :D [COLOR=DarkSlateBlue][B]1 - Add Hibernate annotation dependency.[/B] [/COLOR] [COLOR=DarkSlateBlue]කලින් පාවිච්චි කරපු dependencies වලට අමතරව අපිට තව මේ dependency දෙකත් add කරගන්න වෙනවා! i - hibernate-annotations --> 3.3.0.GA ii - hibernate-commons-annotations --> 3.3.0.GA ඔය? පේනවනේ? [IMG]http://i.imgur.com/J7ncn0f.png[/IMG] ඔන්න මම add කරගත්තා. [B][COLOR=Navy]2 - Update HibernateUtil.java[/COLOR][/B] [COLOR=Navy] මතකයිනේ? එදා අපි හදා ගත්තා HibernateUtil කියලා class එකක්?[/COLOR] [IMG]http://i.imgur.com/Rpzsk7M.png[/IMG] [COLOR=Navy]ඔව් ඔව්! ඔය තියෙන්නේ... ;) ඒක open කරලා line number වලට 13 ට ගිහිල්ලා බැලුවාම උඹලට මෙන්න මෙහෙම code කෑල්ලක් පේන්න ඕනේ. [/COLOR] [SIZE=4][COLOR=DarkSlateGray]return new Configuration().configure().buildSessionFactory();[/COLOR][/SIZE] [COLOR=Navy]තියෙනවා? then good! Folks, අපි දැන් ඒක replace කරගන්න යන්නේ! මෙන්න මේ code කෑල්ලෙන්![/COLOR] [SIZE=4] [COLOR=DarkSlateGray]return new AnnotationConfiguration().configure().buildSessionFactory();[/COLOR][/SIZE] [COLOR=Navy]වෙනස බලාපල්ලා, කලින් code එක out of fashion . ඒක තිබ්බේ xml use කරලා configure කරන්න![/COLOR] [COLOR=Navy]දැං code එක තියෙන්නේ, Annotation use කරලා configure කරන්න![/COLOR] [COLOR=DarkRed][B]3 - Update Model class[/B][/COLOR] [COLOR=DarkRed]මතකයිනේ? අපි එදා අපේ modal class එක හැදුවා Stock කියලා? ආන්න ඒකත් edit කරගන්න ඕනේ. මෙන්න මේ Stock class එක (modal class එක) ට තමයි අපි annotations දාගන්නේ![/COLOR] [COLOR=DarkRed]හරි! මෙන්න මෙහෙමයි edit වෙන්නේ.[/COLOR] [SIZE=4][COLOR=DarkSlateGray]package com.inventory.common; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import static javax.persistence.GenerationType.IDENTITY; import javax.persistence.Id; import javax.persistence.Table; import javax.persistence.UniqueConstraint; @Entity @Table(name = "stock", catalog = "inventory", uniqueConstraints = { @UniqueConstraint(columnNames = "STOCK_NAME"), @UniqueConstraint(columnNames = "STOCK_CODE") }) public class Stock implements java.io.Serializable { private Integer stockId; private String stockCode; private String stockName; public Stock() { } public Stock(String stockCode, String stockName) { this.stockCode = stockCode; this.stockName = stockName; } @Id @GeneratedValue(strategy = IDENTITY) @Column(name = "STOCK_ID", unique = true, nullable = false) public Integer getStockId() { return this.stockId; } public void setStockId(Integer stockId) { this.stockId = stockId; } @Column(name = "STOCK_CODE", unique = true, nullable = false, length = 10) public String getStockCode() { return this.stockCode; } public void setStockCode(String stockCode) { this.stockCode = stockCode; } @Column(name = "STOCK_NAME", unique = true, nullable = false, length = 20) public String getStockName() { return this.stockName; } public void setStockName(String stockName) { this.stockName = stockName; } }[/COLOR][/SIZE] [B][COLOR=Red]** The import javax.persistence cannot be resolved කියලා errors පෙන්නන්න ගත්තොතින් ඔය පහල තියෙන jar එකත් add කරගනිල්ලා. - බොහෝ දුරට add කරගන්න වෙයි උඹලට. - ejb3-persistence --> 1.0.2.GA[/COLOR][/B] [B][COLOR=DarkGreen]4 - Delete existing Hibernate XML mapping file[/COLOR][/B] [COLOR=DarkGreen] Stock.hbm.xml file එක මතකයිනේ? ඔව් ඔව්! mapping file එක තමයි බොලව්. ඔන්න ඔය "හු" යන්න delete කරපියව්! තව දුරටත් ඕකෙන් වැඩක් වෙන්නේ නෑ[/COLOR] [B][COLOR=DarkOrange] 5 - Update Hibernate configuration file.[/COLOR][/B] [COLOR=DarkOrange]දැං Update Hibernate configuration file එක ඔය පහල තියෙන විදියට edit කරගන්න ඕනේ.[/COLOR] [IMG]http://i.imgur.com/STiRpVR.png[/IMG] [COLOR=DarkOrange]මෙන්න මේ විදියට තමයි දැං Update Hibernate configuration file එක පේන්න තියෙන්නේ. [/COLOR] [IMG]http://i.imgur.com/nQ26xr0.png[/IMG] [COLOR=DarkOrange]මේ? දැක්කද full project structure එක?[/COLOR] [IMG]http://i.imgur.com/d2aengt.png[/IMG] [COLOR=DarkOrange]ඔන්න ඒකත් හරි![/COLOR] [B][COLOR=DarkOrange][U]Run කරලා බලන එකයි තියෙන්නේ.[/U] App class උඩ right click කලා --> Run as --> Java application[/COLOR][/B] [IMG]http://i.imgur.com/L4f1gz2.png[/IMG] [COLOR=Indigo]පේනවනේ? මම අළුත් data ටිකක් දාගෙන තියෙන්නේ save කරගන්න. Here is the result.. [/COLOR] [IMG]http://i.imgur.com/qc85jgy.png[/IMG] [COLOR=Indigo]ඔය රතු පාටින් තියෙන්නේ මම අළුතෙන් දාපු data ටික [B]මේ වෙනස සැපයි කියලා හිතනවා උඹලට. [/B] [B]** එහෙම නැත්තන් උඹලට hbm.xml ලිය ලිය බලු කට්ටක් කන්න වෙන්නේ. දැං වැඩේ ලේසිනේ? Model class එකෙන්ම වැඩේ ගොඩ.[/B] [COLOR=Black]හරි! ඊළඟට තියෙන්නේ ටිකක් ලොකු පිම්මක් පනින්න. අපි Maven ගැන ඉගෙන ගන්න යන්නේ. [/COLOR] [B][COLOR=Navy]Maven Athapaththu?? :rofl::rofl::rofl: [/COLOR][/B][IMG]http://p.imgci.com/db/PICTURES/CMS/194400/194497.4.jpg[/IMG] [COLOR=Black]නෑ නෑ! :angry::angry: මේක dependency managment and build automation tool එකක්. [B]ඒ උනාට Maven Athapaththu වගේම තාක්ෂණයෙන් බොහෝම අනූනයි. :yes:[/B] ඔන්න දැන් අපි ටිකෙන් ටික more advanced technologies use කරන්න පටන් ගන්නවා. :cool: ඉතිං basic හරියට නැති කට්ටිය basic brush-up කරගෙනම ඊළඟ lessons වලට join උනොත් තමයි හොඳ. ;) [/COLOR][/COLOR][/COLOR][/SIZE] [SIZE=5][COLOR=DarkSlateBlue][COLOR=Indigo][COLOR=Black][COLOR=#000000][FONT=verdana]මේකට උඹලගේ කැපවීම අනිවාර්යයි! මට පුලුවන් බොලාට මඟ පෙන්නන්න විතරයි! [/FONT][/COLOR]:yes: එහෙනම් හැමෝටම ජය! [/COLOR][/COLOR][/COLOR][/SIZE] [URL="http://www.elakiri.com/forum/tags.php?tag=web+development"]කලින් දාපු lessons ටික මෙතනින් බලල go through කරපල්ලා[/URL] [/QUOTE]
Insert quotes…
Verification
Dahaya deken beduwama keeyada?
Post reply
Top
Bottom