hibernate中数组如何对应到数据库中

public class POJO implements java.io.Serializable { private String[] strs; public String[] getStrs() { return strs; } public void setStrs(String[] strs) { this.strs = strs; }}



为什么不换种思维?

Java code
    
    
    
    
public class POJO implements java.io.Serializable { private Integer id; private String strs; public Integer getId(){ return id; } public void setId(Integer id){ this .id = id; } public String getStrs() { return strs; } public void setStrs(String strs) { this .strs = strs; } } // hbm.xml,假设POJO类路径为com.csdn.bean.POJO <? xml version = " 1.0 " encoding = " utf-8 " ?> <! DOCTYPE hibernate - mapping PUBLIC " -//Hibernate/Hibernate Mapping DTD 3.0//EN " " http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd " > <!-- Mapping file autogenerated by MyEclipse Persistence Tools --> < hibernate - mapping > < class name = " com.csdn.bean.POJO " table = " pojo " > < id name = " id " type = " integer " > < column name = " ID " /> < generator class = " increment " /> </ id > < property name = " strval " type = " string " > < column name = " field_strval " not - null = " true " /> </ property > </ class > </ hibernate - mapping >


当要使用strs时:
String strs = pojo.getStrs();
String[] result = strs.split(",");

你可能感兴趣的:(Hibernate,数据库,String,MyEclipse,Integer,generator)