Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Don´t Close Issue] FAQ - Cosas que vamos a poder necesitar de ahora en adelante #48

Closed
angel96 opened this issue Nov 7, 2018 · 15 comments

Comments

@angel96
Copy link
Owner

angel96 commented Nov 7, 2018

Dadle a editar issue para ver como escribir los caracteres.

Para notacion XML

" "
' '
< <

>
& &

@angel96
Copy link
Owner Author

angel96 commented Nov 7, 2018

Anotaciones de Entidades

@entity
@access(AccessType.PROPERTY)
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)

@angel96
Copy link
Owner Author

angel96 commented Nov 7, 2018

@access(AccesType.PROPERTY) > Le decimos a spring que vamos a utilizar los getters y setters.

@Inheritance > Herencia
@Inheritance (strategy = InheritanceType.TABLE_PER_CLASS)

@id > Identificador en la BBDD
@GeneratedValue(strategy = GenerationType.TABLE) > Delegamos la estrategia de generar el Id unico a la base de datos.

@Version > Actualizaciones de esa entidad por versión

Cuando redefinimos el equals, el hashcode también.

@embeddable > Clase embebible. Los atributos se van a meter en la tabla.

@ElementCollection > IMPORTANTE ponerlo si hacemos un collection de datatypes

@OneToMany
A B
1 -> 1..*

  • Para cada instancia de B le corresponde una de A

Composicion > Recordar el ejemplo del ordenador (Para existir un objeto ordenador tiene que existir todos sus componentes)

mappedBy > Poner en una de las dos relaciones
Ejemplo: Reviewer (Collection de announcement - OneToMany) y Announcement (El collection de announcement tiene un unico reviewer - ManyToOne)

Unique > @column(unique = true)
Varios uniques > @table(uniqueConstraints = @UniqueConstraint(columnNames = {"databaseColumn1", "databaseColumn2"}))

@TeMPOraL(TemporalType.TIMESTAMP) > Para fechas

  • TIMESTAMP: Me devuelve hora y fecha.
  • DATE: Fecha
  • TIME: Hora

@transient > Atributos derivados que no queremos persistir.

Con funciones de agregacion (count, match...) > groupBy en la query JPQL
Condiciones con funciones de agregacion > having count(r) >= 3

@angel96 angel96 moved this from To do to Done in L02 - Domain Models Nov 7, 2018
@angel96
Copy link
Owner Author

angel96 commented Nov 7, 2018

FIJAROS QUE LA TABLA DE LA SENTENCIA JPQL ESTA ESCRITA CON EL NOMBRE DE LA CLASE JAVA, NO CON EL NOMBRE Y EL FORMATO QUE SE REGISTRA EN MYSQL.

select a from Administrator a
> ;
1 object selected
Actor [name=Administrator1, middleName=Administrator1Middle, surname=Administrator1Surname, photo=https://www.photo.com,
email=admin<administrator@>, phone=954152635, numberProfiles=2]
domain.DomainEntity::id: int = 44
domain.DomainEntity::version: int = 0
domain.Actor::name: java.lang.String = "Administrator1"
domain.Actor::middleName: java.lang.String = "Administrator1Middle"
domain.Actor::surname: java.lang.String = "Administrator1Surname"
domain.Actor::photo: java.lang.String = "https://www.photo.com"
domain.Actor::email: java.lang.String = "admin<administrator@>"
domain.Actor::phone: java.lang.String = "954152635"
domain.Actor::adress: java.lang.String = "C/Reina Mercedes"
domain.Actor::numberProfiles: java.lang.Integer = 2
domain.Actor::account: security.UserAccount = security.UserAccount{id=23, version=0}
domain.Actor::profiles: java.util.Collection = [domain.Profile{id=38, version=0}, domain.Profile{id=39, version=0}]
domain.Actor::message: java.util.Collection = []
domain.Actor::ban: boolean = false

@angel96
Copy link
Owner Author

angel96 commented Nov 7, 2018

@notblank lo usamos para cadenas.
@NotNull lo utilizamos para comprobar que los tipos no sean nulos.

  • Recordad que el tipo integer primitivo no puede ser nulo

@angel96 angel96 changed the title FAQ - Cosas que vamos a poder necesitar de ahora en adelante [Don´t Close Issue] FAQ - Cosas que vamos a poder necesitar de ahora en adelante Nov 7, 2018
@angel96
Copy link
Owner Author

angel96 commented Nov 7, 2018

Script MySQL

drop database if exists Acme-HandyWork;
create database Acme-HandyWork;
#drop user 'acme-user'@'%';
#drop user 'acme-manager'@'%';
create user 'acme-user'@'%'
identified by 'ACME-Us3r-P@ssw0rd';

create user 'acme-manager'@'%'
identified by 'ACME-M@n@ger-6874';

grant select, insert, update, delete
on Acme-HandyWork.* to 'acme-user'@'%';
grant select, insert, update, delete, create, drop, references, index, alter,
create temporary tables, lock tables, create view, create routine,
alter routine, execute, trigger, show view
on Acme-HandyWork.* to 'acme-manager'@'%';

@angel96 angel96 added this to To do in L03 - Persistence Nov 13, 2018
@angel96 angel96 moved this from To do to Done in L03 - Persistence Nov 16, 2018
@angel96 angel96 added this to To do in L04 - Repositories and Services via automation Nov 16, 2018
@angel96
Copy link
Owner Author

angel96 commented Nov 17, 2018

Variables booleanas no pueden comenzar por 'is'. Deben tener otro nombre distinto porque si no el setter no lo coge bien Spring.
imagen

@angel96 angel96 moved this from To do to Done in L04 - Repositories and Services Nov 17, 2018
@angel96
Copy link
Owner Author

angel96 commented Nov 23, 2018

El @Autowired se coloca a cada servicio que llamemos
imagen

@angel96
Copy link
Owner Author

angel96 commented Nov 29, 2018

No colocar ningun toString en las entidades. Provoca StackOverFlow a la hora de cargar el PopulateDatabase

@belengl belengl added this to To do in L05 - Views via automation Nov 30, 2018
@angel96
Copy link
Owner Author

angel96 commented Nov 30, 2018

Si un formulario falla, comprobar que tiene el <form:hidden ... >

@angel96
Copy link
Owner Author

angel96 commented Nov 30, 2018

Usar placeholders

@angel96
Copy link
Owner Author

angel96 commented Nov 30, 2018

Errata en diapositiva
imagen

@angel96
Copy link
Owner Author

angel96 commented Dec 12, 2018

Fechas en Spring

ADVERTENCIA: VER ESTA ISSUE EN MODO EDICION
Paso 1.

<script> $(function() { $("#datepicker-1").datepicker({ appendText : "(yy-mm-dd)", dateFormat : "yy-mm-dd" }); }); </script>

Paso 2. <form:label path="">
<spring:message code="finder.date1" />
</form:label>
<form:input path="" type="text" id="datepicker-1" />

Paso 3.
imagen

@angel96 angel96 moved this from To do to Done in L05 - Views Dec 12, 2018
@angel96 angel96 added this to To do in L06 - Controllers via automation Dec 13, 2018
@angel96 angel96 moved this from To do to Done in L06 - Controllers Dec 13, 2018
@angel96
Copy link
Owner Author

angel96 commented Dec 16, 2018

El atributo del formulario:

modelAttribute = "announcement"

El nombre de la variable que le pasamos al metodo controlador:

@Valid Announcement announcement

Tienen que llamarse igual para que la validación en formulario funcione

@angel96 angel96 moved this from Done to Issues Neutras in L06 - Controllers Dec 18, 2018
@angel96 angel96 added this to To do in L07 - Deployment via automation Dec 27, 2018
@angel96 angel96 moved this from Issues Neutras to Done in L06 - Controllers Jan 10, 2019
@angel96 angel96 moved this from To do to Done in L07 - Deployment Jan 11, 2019
@angel96 angel96 closed this as completed Jan 17, 2019
@angel96 angel96 reopened this Jan 19, 2019
L03 - Persistence automation moved this from Done to To do Jan 19, 2019
L04 - Repositories and Services automation moved this from Done to In progress Jan 19, 2019
L05 - Views automation moved this from Done to In progress Jan 19, 2019
L06 - Controllers automation moved this from Done to In progress Jan 19, 2019
L07 - Deployment automation moved this from Done to In progress Jan 19, 2019
@angel96 angel96 added this to Issues importantes in L08 - Control Checks Jan 19, 2019
@angel96 angel96 moved this from In progress to Done in L07 - Deployment Jan 19, 2019
@angel96 angel96 moved this from To do to Done in L03 - Persistence Jan 19, 2019
@angel96 angel96 moved this from In progress to Done in L05 - Views Jan 19, 2019
@angel96 angel96 moved this from In progress to Done in L04 - Repositories and Services Jan 19, 2019
@angel96
Copy link
Owner Author

angel96 commented Jan 21, 2019

Pagina util para realizar patterns

https://www.debuggex.com/r/EFJ6hmjEF4B78PcA

@angel96 angel96 closed this as completed Feb 12, 2019
L06 - Controllers automation moved this from In progress to Done Feb 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants