Example usage for org.hibernate.collection.internal PersistentSet add

List of usage examples for org.hibernate.collection.internal PersistentSet add

Introduction

In this page you can find the example usage for org.hibernate.collection.internal PersistentSet add.

Prototype

@Override
    public boolean add(Object value) 

Source Link

Usage

From source file:com.erinors.hpb.server.handler.SetHandler.java

License:Apache License

@Override
public Object clone(CloningContext context, Object object) {
    if (!(object instanceof Set)) {
        return null;
    }/* w  w  w. j  a  v a 2s.c om*/

    Set<?> source = (Set<?>) object;
    Set<?> result;

    if (source instanceof PersistentSet) {
        if (((PersistentSet) source).wasInitialized()) {
            com.erinors.hpb.shared.impl.PersistentSet<Object> set = new com.erinors.hpb.shared.impl.PersistentSet<Object>(
                    source.size());
            context.addProcessedObject(object, set);

            for (Object element : source) {
                set.add(context.clone(element));
            }

            set.setDirty(((PersistentCollection) source).isDirty());

            result = set;
        } else {
            result = new UninitializedPersistentSet<Object>();
            context.addProcessedObject(object, result);
        }
    } else {
        Set<Object> set = new HashSet<Object>(source.size());
        context.addProcessedObject(object, set);

        for (Object element : source) {
            set.add(context.clone(element));
        }

        result = set;
    }

    return result;
}

From source file:com.erinors.hpb.server.handler.SetHandler.java

License:Apache License

@Override
public Object merge(MergingContext context, Object object) {
    if (!(object instanceof Set)) {
        return null;
    }/*from ww w . j  a  v  a2 s  . co  m*/

    Set<?> source = (Set<?>) object;
    Set<?> result;

    if (source instanceof UninitializedPersistentSet) {
        result = new PersistentSet(context.getSessionImplementor());
        context.addProcessedObject(object, result);
    } else if (source instanceof com.erinors.hpb.shared.impl.PersistentSet) {
        PersistentSet set = new PersistentSet(context.getSessionImplementor(), new HashSet<Object>());
        context.addProcessedObject(object, set);

        for (Object element : source) {
            set.add(context.merge(element));
        }

        if (((com.erinors.hpb.shared.impl.PersistentSet<?>) source).isDirty()) {
            set.dirty();
        } else {
            set.clearDirty();
        }

        result = set;
    } else {
        Set<Object> set = new HashSet<Object>(source.size());
        context.addProcessedObject(object, set);

        for (Object element : source) {
            set.add(context.merge(element));
        }

        result = set;
    }

    return result;
}

From source file:marmar.ganaderia_fxml.gui.FXMLDocumentController.java

@FXML
private void handleButtonRegVacunaGuardar(ActionEvent e) {
    //TODO/*  w w  w  . j a va  2  s. c  o  m*/
    String f = dpRegVacunaFecha.getEditor().getText();
    String vacuna = tfRegVacuna.getText();
    String veterinario = tfRegVacunaVeterinario.getText();
    String comentario = tfRegVacunaComentario.getText();

    if (f != null && !f.isEmpty() && vacuna != null && !vacuna.isEmpty() && veterinario != null
            && !veterinario.isEmpty() && comentario != null && !comentario.isEmpty()) {

        Date fecha = new Date(f);

        Vacunacion vac = new Vacunacion(vacuna, veterinario, comentario, fecha);
        //            convacuna.saveNew(vac);
        Bovino b;
        PersistentSet hs;

        ObservableList<Bovino> items = listRegVacunaRight.getItems();
        for (Bovino item : items) {
            b = item;
            hs = (PersistentSet) b.getVacunas();
            hs.add(vac);
            conbovino.update(b);
        }

        fillRegVacunaTab();
        System.out.println("Finished with the vacunas");
    }
    actualizarVacunacionTab();
}

From source file:marmar.ganaderia_fxml.gui.RegistrarController.java

@FXML
private void handleButtonRegVacunaGuardar(ActionEvent e) {
    //TODO/*  w  w  w.  ja  v  a  2  s  .  c  o m*/
    String f = dpRegVacunaFecha.getEditor().getText();
    String vacuna = tfRegVacuna.getText();
    String veterinario = tfRegVacunaVeterinario.getText();
    String comentario = tfRegVacunaComentario.getText();

    if (f != null && !f.isEmpty() && vacuna != null && !vacuna.isEmpty() && veterinario != null
            && !veterinario.isEmpty() && comentario != null && !comentario.isEmpty()) {

        Date fecha = new Date(f);

        Vacunacion vac = new Vacunacion(vacuna, veterinario, comentario, fecha);
        //            convacuna.saveNew(vac);
        Bovino b;
        PersistentSet hs;

        ObservableList<Bovino> items = listRegVacunaRight.getItems();
        for (Bovino item : items) {
            b = item;
            hs = (PersistentSet) b.getVacunas();
            hs.add(vac);
            conbovino.update(b);
        }

        fillRegVacunaTab();
        System.out.println("Finished with the vacunas");
    }
    //        actualizarVacunacionTab();
}