Annotations Flashcards

1
Q

@Autowired

A

@Component

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

@Component

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

@ID

A

Use for Spring Data?
Generates the id automatically (PK in db???)
@Id–> from jakarta? JPA?
@Id –> form Springdata–> for reactive progaming?
JPA vs R2DBC?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

@CreatedDate
@LastModifiedDate

A

–> from SpringData
–> they neeD the @EnableR2dbcAuditing annotation on the db @Configuration classs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Test annotation

A

@DataR2dbctest –> test slice

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

@Import(YourClass.class)

A

-> is this used in the test classes when using onlt test slicing OR???

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

@RestCOntroller

A

to implement the enpoints in the cotrollers package

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

@service

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

@mapper

A

Used with mapstruct maven plugin, mapstruct depedency
annotation an interface that has methods to transform from EntityToDto and from DtoToEntity

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Difference between @Bean and @Autowired

A

@Bean tells Spring ‘here is an instance of this class, please keep hold of it and give it back to me when I ask’.

@Autowired says ‘please give me an instance of this class, for example, one that I created with an @Bean annotation earlier’.

**it becomes useful if you have the @Bean defined in one class, and the @Autowired in a different one.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

On fields:
@NotBlank
@Size(min=1, max=255)

A

–> used whe adding mavn dependency: spring-boot-starter-validation
–> use class org.springframework.validation.Validator class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

JPA Annotation

A

@Entity
Annotation on class–>in package domain –> the object that will be persisted to DB via JPA(Hibernate?)
Field annotations:

*for id:
@Id
@GeneratedValue(generator=”UUID”)
@GenericGenerator(name=”UUID”, strategy=”org.hibernate.id.UUIDGenerator”)
@Type(type=”org.hibernate.type.UUIDCharType”)
@Column(lenght=36, columnDefinition=”varchar”, updatable=false, nullable=false)

*for version:
@Version

*for date:
@CreationTimestamp
@Column(updatable=false)

@UpdateTimestamp

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Sprin MVC annatations

A

On controller calsses:
@RequestMapping(“/api/v1/”)
@RestController
ON methods:
@GetMapping(produces={“application/json”},path=”beer”)
@GetMapping(“/path/{requestParam}”)
–> in parameters of the method (@PathVariable(“pathVariable”) Type localVarible, @RequestParam(value=showInventory,required=false) Boolean showInventory)
@PostMapping(“path”)
–> in method param
(@RequestBody @Validated BeetDTO beerDTO)
@PutMapping(“path”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly