똑같이 작성후 select * from account;
똑같이 작성후 select * from account; 를 해도 아무변화가 일어나지않네요 .. 왜그럴까요? ㅠㅠ 적용이 안된다고 해야하나..
오류는 일어나지않습니다.
package me.whiteship.demospring;
import org.hibernate.Session;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
@Component
@Transactional
public class JpaRunner implements ApplicationRunner {
@PersistenceContext
EntityManager entityManager;
@Override
public void run(ApplicationArguments args) throws Exception {
Account account = new Account();
account.setUsername("whiteship");
account.setPassword("jpa");
Session session = entityManager.unwrap(Session.class);
session.save(account);
}
}
spring.datasource.url=jdbc:postgresql://localhost:5432/springdata
spring.datasource.username=postgres
spring.datasource.password=pass
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.jdbc.lob.non_contxtual_creation=true
public void run(ApplicationArguments args) throws Exception {
Account account = new Account();
account.setUsername("aaaaa");
account.setPassword("jpa");
Session session = entityManager.unwrap(Session.class);
session.save(account);
System.out.println(account.getUsername());
System.out.println(account.getPassword());
}
}
이렇게 출력해보니까
2020-06-11 15:39:08.303 INFO 18983 --- [ task-1] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2020-06-11 15:39:08.312 INFO 18983 --- [ task-1] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
aaaaa
jpa
2020-06-11 15:40:08.323 INFO 18983 --- [extShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
나오긴나오는것 같은데 터미널에는 아~무 이상이 없어요 ㅠㅠ email도 추가 되지않았구요
혹시 이것도 관계가 있을가요?
springdata=# \list
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
------------+----------+----------+------------+------------+-----------------------
postgres | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
springdata | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
template0 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres +
| | | | | postgres=CTc/postgres
(4 rows)
Acces privileges..
데이터베이스 지우면 springdata없다고 인텔리제이에서 오류나고,
생성하면 username, password는 커녕 account 테이블 생성조차 안되네요 ㅠㅠ
답변 5
0
spring.jpa.hibernate.ddl-auto=update
이 설정이 있다면 만들 수 있어야 하는데 뭔가 이상하네요. 도커 말고 PostgreSQL DB를 직접 설치해서 써보세요. Pgadmin 같은 툴을 써서 보시면 좀 더 편하게 보실 수도 있을테구요.
0
터미널로 crate table account;를 해야 보여요..
선생님께서는 Uesr로 만드시는 예제를 보여주실때 삭제하고 run을 했을경우 자동으로 생성되었잖아요? 그런데 전 생기지도 않습니다..
spring boot 2.7.13-SNAPSHOT trace 소문자 로그 안나옴
0
533
1
<스프링 데이터 Common: 기본 리포지토리 커스터마이징> 에 대한 질문
0
392
1
comment table에서 저장될떄 왜 id값이 2부터저장이되는건가요?
0
407
1
@EnableJpaRepositories 설정을 스프링부트가 어디에서 자동설정하나요?
0
450
0
PersistenceContext 관련 질문드립니다.
0
335
1
지금(Eager), 나중에(Lazy)의 의미를 모르겠습니다
0
338
1
transaction 구간이 길어질 경우의 처리방법 문의드립니다.
0
905
1
docker postgres
0
292
1
Multiple DataSource 사용 시 transaction 관련 질문 드립니다.
0
2908
1
entity 중 null이 아닌 필드만 update 할 방법이 있을까요?
0
1190
1
Eager 모드일 경우, join을 inner join으로 바꾸는 법이 있을까요?
0
385
1
엔티티를 상속받는 DTO가 일반적인가요?
1
1847
1
커스텀 타입 클래스를 String 타입 처럼 이용해 쿼리하는 방법에 대해 질문하고 싶습니다.
0
339
1
연관관계 매핑 어떤식으로 해야될지 감이 안잡힙니다.
0
566
4
EntityManager 주입시 Annotation관련 질문드립니다.
0
565
1
클래스 기반 프로젝션 사용 관련 질문
0
560
1
save 메서드 질문드립니다.
0
258
1
복잡한 통계쿼리도 JPA로 가능한가요?
2
5592
1
find 와 get의 차이가 무엇인가요?
0
890
1
실무에서 JPA 할 때 FK로 개발할때 연관관계를 꼭 맺어주어야 하나요?
0
998
1
\dt Did not find any relations.
0
481
1
소스코드는 어디서 볼 수 있을까요?
1
287
1
table 생성과 select 문에 대한 질문
0
174
1
스프링 데이터 RepositoryTest 관련 질문
0
2173
2





