Problems with java strings

1

I am doing a migration of data from a csv file to a H2 database. In this process I use the beanio to read the file and transform it into objects and then persist the objects in the base using jpa + hibernate.

The problem is strange because when reading the file the description property of the first read object is

Does anyone have any idea what this is?

Beanio xml

    <stream name="produto" format="csv">
    <parser>
        <property name="delimiter" value=";" />
        <property name="lineSeparator" value="\n" />
        <property name="whitespaceAllowed" value="true" />
    </parser>
    <typeHandler type="java.util.Date" class="com.nexccs.typehandlers.DateTypeHandler" />
    <typeHandler name="LongHandler" class="com.nexccs.typehandlers.LongTypeHandler" />
    <typeHandler name="IntegerHandler" class="com.nexccs.typehandlers.IntegerTypeHandler" />
    <typeHandler name="UsuarioHandler" class="com.nexccs.typehandlers.UsuarioTypeHandler" />
    <typeHandler name="CategoriaHandler" class="com.nexccs.typehandlers.StringCategoriaHandler" />
    <typeHandler name="UnidadeMedidaHandler" class="com.nexccs.typehandlers.StringUnidadeMedidaHandler" />
    <typeHandler name="FornecedorHandler" class="com.nexccs.typehandlers.FornecedorHandler" />
    <typeHandler name="MoneyHandler" class="com.nexccs.typehandlers.MoneyToBigDecimalHandler" />
    <typeHandler name="CommaToDecimalPointerBigDecimal" class="com.nexccs.typehandlers.CommaToDecimalPointerBigDecimalTypeHandler" />
    <record name="produto" class="com.nexccs.model.Produto">
        <field name="descricao" />
        <field name="codigo" />
        <field name="qtdEstoque" typeHandler="CommaToDecimalPointerBigDecimal"/>
        <field name="preco" typeHandler="MoneyHandler"/>
        <field name="margem" typeHandler="CommaToDecimalPointerBigDecimal"/>
        <field name="custo" typeHandler="MoneyHandler"/>
        <segment name="categoria" class="com.nexccs.model.Categoria" lazy="true">
            <field name="descricao" typeHandler="CategoriaHandler"/>
        </segment>
        <segment name="unidadeMedida" class="com.nexccs.model.UnidadeMedida" lazy="true">
            <field name="descricao" typeHandler="UnidadeMedidaHandler"/>
        </segment>
        <segment name="fornecedor" class="com.nexccs.model.Fornecedor" lazy="true">
            <field name="id" typeHandler="FornecedorHandler" trim="true"/>
        </segment>
        <field name="tributacao" />
        <field name="ncm" />
    </record>
</stream>

Product Class

@Entity @Table(name="produtos")
public class Produto implements Serializable{

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY) 
private Long id;

@Column(name="cod_produto")
private String codigo;

@Column(name="desc_produto")
private String descricao;

csv file used

Excerpt of code parsing and saving in db

StreamFactory factory = StreamFactory.newInstance();
        // load the mapping file
        factory.load(resourcePath_beanio + tabelaArquivo[0].toLowerCase() + ".xml");

        //create reader
        BeanReader in = factory.createReader(tabelaArquivo[0].toLowerCase(), new File(tabelaArquivo[1]));
        Object  entity;

        //list of details
        Set<Object> entities = new HashSet<>();

        //add details to list
        while ((entity = (Object) in.read()) != null) {
            entities.add(entity);

        }

        Class<AbstractDAO<Object, Long>> dao = (Class<AbstractDAO<Object, Long>>) Class.forName(packageRoot_dao + tabelaArquivo[0] + "DAO");

        Ambiente.getInstance().setBatch();

        //save details on DB
        dao.newInstance().saveAll(entities);
       ...
    
asked by anonymous 01.02.2018 / 15:38

0 answers