해결된 질문
작성
·
388
0
똑같이 작성후 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 테이블 생성조차 안되네요 ㅠㅠ