forked from Impetus/kundera
-
Notifications
You must be signed in to change notification settings - Fork 0
Oracle NoSQL Reading Writing LOBs
xamry edited this page Jul 11, 2013
·
3 revisions
OracleNoSQL supports reading/ writing of Large Objects LOBs such as audio and video files. Using Kundera, you can read/ write LOBs using attribute of type java.io.File in entity classes.
Here is an example:
@Entity
@Table(name = "USER_PROFILE", schema = "HR_Store@oracle_nosql_pu")
public class UserProfile
{
@Id
@Column(name = "USER_ID")
private int userId;
@Column(name = "USER_NAME")
private String userName;
@Column(name = "PROFILE_PICTURE")
private File profilePicture;
public UserProfile(int userId, String userName, File profilePicture)
{
super();
this.userId = userId;
this.userName = userName;
this.profilePicture = profilePicture;
}
//Getters and setters
}
LOBExample.java (Snippet)
//Insert user profile alongwith picture
File file = new File("/home/amresh/MyPhoto.jpg");
long fileSize = file.getTotalSpace();
UserProfile userProfile = new UserProfile(1, "Amresh", file);
em.persist(userProfile);
//Clear Cache
em.clear();
//Find user profile
UserProfile up = (UserProfile) em.find(UserProfile.class, 1);
File myPicture = up.getProfilePicture();
//Delete Profile
em.remove(userProfile);
Note: Before performing LOB operations, you can configure below parameters that are applied on all operations until em.close() is called. (In absence, default OracleNoSQL settings are applied).
em.setProperty("write.timeout", 10);
em.setProperty("durability", Durability.COMMIT_WRITE_NO_SYNC);
em.setProperty("time.unit", TimeUnit.SECONDS);
em.setProperty("consistency", Consistency.NONE_REQUIRED);
Previous | Home | Next |
-
Entity to Key-Value store mapping
-
Oracle NoSQL Configuration
-
OracleNoSQL CRUD
-
Oracle NoSQL Storage of Embedded Objects
-
Oracle NoSQL Inverted Indexing
-
OracleNoSQL JPA Queries
-
Oracle NoSQL Reading Writing LOBs
- Oracle NoSQL Wishlist
[Kundera Wiki Home] (https://github.com/impetus-opensource/Kundera/wiki)