There are too many table fields and you don't want to save them separately to the data, so use a low frequency, so consider using the Jave class--JSON data conversion.
1. Class conversion JSON, and save to data
Attribute.java
1 /**2 * Attribute data structure3 *4 */5 Public classAttribute {6 7 Private Static Final LongSerialversionuid = -1l;8 9 PrivateLong Attrid;Ten One PrivateList<attributevalue>attributevalues; A - PrivateLong catid; - the PrivateString Cnname; - - PrivateBoolean customizeimage; - + PrivateBoolean Customizevalue; - + PrivateString Enname; A at PrivateString InputType; - - PrivateBoolean keyattr; - - PrivateBoolean Locator; - in PrivateLong order; - to PrivateLong Parentvalue; + - PrivateBoolean required; the * PrivateList<string> units;
Attribute.java
Attributeservice.java
1 // convert to JSON string 2 list<attribute> attributes = response.getattributes (); 3 Jsonarray jsonarray = jsonarray.fromobject (attributes); 4 // Save to data 5 this. Save (Jsonarray.tostring ());
2. JSON conversion into class
Attributeservice.java
1 //get JSON properties from the database2String Jsonattribute = This. getattribute ();3 //convert to JSON array4Jsonarray jsonattr =Jsonarray.fromobject (jsonattribute);5 //because the attribute class contains List<attributevalue>, you need to add a subset6map<string, class> classmap =NewHashmap<string, class>(); 7Classmap.put ("Attributevalues", AttributeValue.class); 8 //Final Convert List object complete9List<attribute> listproductattributes = (list<attribute>) jsonarray.tolist (jsonAttr, Attribute.class, Classmap);
Another way to deal with the data, this will be more simple, the operation of the database more convenient, but in the database is not easy to read, page-side display and sub-table sub-field storage no difference.
Conversion between Java class objects and JSON data