Last active
April 30, 2024 16:13
-
-
Save lol97/41b15c4a5297ddb82e0b5bd6b2d792d1 to your computer and use it in GitHub Desktop.
model for article Spring boot Hibernate Basic 1 CRUD Menggunakan database H2 (sufyan97.com)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.sufyan97.learn_hibernate.barang; | |
| import java.math.BigDecimal; | |
| import jakarta.persistence.Column; | |
| import jakarta.persistence.Entity; | |
| import jakarta.persistence.GeneratedValue; | |
| import jakarta.persistence.GenerationType; | |
| import jakarta.persistence.Id; | |
| import jakarta.persistence.Table; | |
| @Table | |
| @Entity | |
| public class Barang { | |
| @Id | |
| @GeneratedValue(strategy = GenerationType.IDENTITY) | |
| private Long id; | |
| @Column(name = "NAMA") | |
| private String nama; | |
| @Column(name = "HARGA_SATUAN") | |
| private BigDecimal hargaSatuan; | |
| @Column(name = "STOCK") | |
| private BigDecimal stock; | |
| public Barang(Long id, String nama, BigDecimal hargaSatuan, BigDecimal stock) { | |
| super(); | |
| this.id = id; | |
| this.nama = nama; | |
| this.hargaSatuan = hargaSatuan; | |
| this.stock = stock; | |
| } | |
| public Barang(String nama, BigDecimal hargaSatuan, BigDecimal stock) { | |
| super(); | |
| this.nama = nama; | |
| this.hargaSatuan = hargaSatuan; | |
| this.stock = stock; | |
| } | |
| public Barang() { | |
| super(); | |
| } | |
| public Long getId() { | |
| return id; | |
| } | |
| public void setId(Long id) { | |
| this.id = id; | |
| } | |
| public String getNama() { | |
| return nama; | |
| } | |
| public void setNama(String nama) { | |
| this.nama = nama; | |
| } | |
| public BigDecimal getHargaSatuan() { | |
| return hargaSatuan; | |
| } | |
| public void setHargaSatuan(BigDecimal hargaSatuan) { | |
| this.hargaSatuan = hargaSatuan; | |
| } | |
| public BigDecimal getStock() { | |
| return stock; | |
| } | |
| public void setStock(BigDecimal stock) { | |
| this.stock = stock; | |
| } | |
| @Override | |
| public String toString() { | |
| return "Barang [id=" + id + ", nama=" + nama + ", hargaSatuan=" + hargaSatuan + ", stock=" + stock + "]"; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment