Skip to content

Instantly share code, notes, and snippets.

View toficzak's full-sized avatar
🐱

Toficzak toficzak

🐱
View GitHub Profile
MONGO_PORT=
MONGO_DB=
MONGO_USERNAME=
MONGO_PASSWORD=
MONGO_INITDB_ROOT_USERNAME=
MONGO_INITDB_ROOT_PASSWORD=
MONGO_INITDB_DATABASE=
LOG_LEVEL=DEBUG
version: '3.8'
services:
mongodb:
image: mongo
container_name: ${MONGO_CONTAINER_NAME}
command: mongod --port ${MONGO_PORT}
volumes:
- mongodb_data:/data/db
- ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js
@toficzak
toficzak / create_pg_container.sh
Created January 8, 2023 19:52
Create postgres container
docker run -d --name <name> -v <volume_path>:/var/lib/postgresql/data -e POSTGRES_PASSWORD=<password> -e POSTGRES_USER=<username> -e POSTGRES_DB=<database_name> postgres:<tag>-alpine
@Entity
@Table(name = "users")
public class User extends BaseEntity {
}
@Entity
public class Post extends BaseEntity {
@NotBlank
--> By author id:
Hibernate:
select
post0_.id as id1_0_,
post0_.author_id as author_i3_0_,
post0_.message as message2_0_
from
post post0_
left outer join
users user1_
startTime = System.nanoTime();
method();
endTime = System.nanoTime();
duration = (endTime - startTime);
results.add(duration);
average = results.stream().mapToLong(Long::longValue).average().getAsDouble()
@Repository
public interface PostRepository extends CrudRepository<Post, Long> {
Optional<Post> findTopByAuthorOrderByIdDesc(User author);
Optional<Post> findTopByAuthorIdOrderByIdDesc(Long authorId);
@Query("from Post where author_id = ?1 order by id desc")
Optional<Post> findWithCustomQueryOrderByIdDesc(Long authorId);
@Rule
public TemporaryFolder testFolder = new TemporaryFolder();
private String filePath;
private final String FILENAME = "testCsvFile.csv";
@Test
public void generate___shouldSucceed() throws IOException {
@toficzak
toficzak / 1BaseTeam.java
Created October 20, 2019 12:07
Team entities
import java.util.Collection;
import javax.persistence.ManyToMany;
import javax.persistence.MappedSuperclass;
import javax.persistence.OneToMany;
import weapon.rental.BaseEntity;
import weapon.rental.hero.domain.Hero;
import weapon.rental.invitation.Invitation;
package krzysztof.javaee8.config;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
@ApplicationPath("/api")
public class JaxRsActivator extends Application{
}