• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can I serialize a java object to Varchar field in a database  RSS feed

 
Rajesh Nandhamuri
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can I serialize a java object to Varchar field in a database?
 
Antonio Tercero
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'd better choose a binary field (blob).
But the most common way to serialize an object is defining
a field in your table for each atribute of your class.


For example:

class Person{
private int id;
private String name;
// getters and setters
}

In your database:

CREATE TABLE Person(
id int not null primary key,
name varchar(50) NOT NULL );

You can use Hibernate in your application to do all the mappings and persist
your objects.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!