SBMS 6am 25012023
SBMS 6am 25012023
SBMS 6am 25012023
*) Now a days, Cloud Buckets are used to store data for LOBs.
Ex: AWS S3 (Simple Storage Service) Buckets.
==> These are standard names given by SQL (also followed by few databases)
BLOB = byte[] + @Lob (JPA)
CLOB = char[] + @Lob
=======Ex==========================================================
1. YAML
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/boot6am
username: root
password: root
jpa:
database-platform: org.hibernate.dialect.MySQL8Dialect
show-sql: true
hibernate:
ddl-auto: update
2. Entity
package com.app.raghu.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name="prodtab")
public class Product {
@Id
@Column(name="pid")
private Integer prodId;
@Column(name="pcode")
private String prodCode;
@Column(name="pcost")
private Double prodCost;
@Lob //BLOB
@Column(name="pimg")
private byte[] prodImg;
@Lob //CLOB
@Column(name="pdsc")
private char[] prodDesc;
}
3. Repository interface
package com.app.raghu.repo;
import org.springframework.data.jpa.repository.JpaRepository;
import com.app.raghu.entity.Product;
4. Runner class
package com.app.raghu.runner;
import java.io.FileInputStream;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import com.app.raghu.entity.Product;
import com.app.raghu.repo.ProductRepository;
@Component
public class ProductRunner implements CommandLineRunner {
@Autowired
private ProductRepository repo;
String input ="HEllo welcome ?! How are you ? where are you..
congrats ... text me when you see this message...............";
char[] carr = input.toCharArray();
repo.save(p);
fis.close();
}
}
==========================================
Commit
Rollback
ACID Properties
==========================================