A라는 엔터티와 B라는 엔터티가 있고, 이것의 관계가 1:N이라는 관계에 있다고 가정했을 때 repository를 생성할 때 , ARepository만 만들거나, BRepository를 만들거나, ARepositry 와 BRepository를 만드는 경우가 있을 거 같은대요. 혹시 각각의 경우에 대해서 알려주실 수 있을까요? 전 무의적으로 각각의 Entity에대해서 Repository를 만드는 것 같아서요 ㅎㅎ;
푸터 위에 배너 부분에서 질문입니다. 한솔 홈데코 사이트가 개편 되어서 배너 부분이 바뀌었습니다. 그래서 강의 처럼 li a 에 이미지를 넣고 싶은데 사이즈가 몇인지 몰라서 대체 이미지를 못 넣고 있습니다. 해당 이미지가 몇인지 궁금합니다. 이미지가 들어가는 위치는 .banner ul li:nth-child(1) a {background: url(../img/bg_main_bussiness_link01.jpg) no-repeat;} .banner ul li:nth-child(2) a {background: url(../img/bg_main_bussiness_link02.jpg) no-repeat;} .banner ul li:nth-child(3) a {background: url(../img/bg_main_bussiness_link03.jpg) no-repeat;} .banner ul li:nth-child(4) a {background: url(../img/bg_main_bussiness_link04.jpg) no-repeat;} 궁금합니다. 참, 그리고 배너 전체 배경 이미지는 사이즈 너비가 1980px이 맞는지 궁금합니다.
c나 c++에서 한 프로젝트에 두 개 이상의 소스파일이 있을 때, 가령 1.c와 2.c가 있다할 때, 둘 다 메인함수 코드를 작성해놓고, 하나만(예를 들어 2.c의 메인함수만) 실행하고 싶다면, 1.c에 있는 메인함수를 "int main_1" 이런 식으로 써놓으면 2.c의 메인함수만 실행하잖아요. 다 주석처리 할 필요없이 말이죠 c++에는 c에서도 사용하는 사용자 정의 함수도 많고 클래스나 네임스페이스 부가적인 같은 것들이 많잖아요? 메인함수의 저런 편의 기능처럼. 클래스나 네임스페이스나 사용자 정의 함수도 그렇게 한 곳의 소스파일에 있는 것만 실행 되게 하는 편한 방법 이 없을까요?? (주석처리하는 방법 말고...... 다른 것만 알려주세요...주석처리 밖에 없는건가요? 아니면 아예 " 소스파일 하나를 통째로 실행시키지 않는 방법 "을 원합니다.....) 정적멤버 1강이랑 2강을 따로 두개의 소스파일로 만들어서 실행하려고 했거든요. 이렇게 공부하는 버릇이 있어서요, 알려주세용 ㅜㅠ
우선순위 큐에서의 구조체 struct Edge{ int e; int val; Edge(int a, int b){ e=a; val=b; } bool operator<(const Edge &b)const{ // return val>b.val; } }; 벡터를 sort 하기 위한 목적의 구조체 struct Edge{ int s; int e; int val; Edge(int a, int b, int c){ s=a; e=b; val=c; } bool operator<(Edge &b){ return val<b.val; } }; 선생님 구조체 안의 bool operator라는 함수를 쓰는것은 처음봐서 저것이 어떻게 동작할수 있는지 이해가 잘 가지 않습니다. 1.이것에 대해 이해하려면 어떤 것을 공부 해야하는지요 2. 둘다 최소 cost를 찾기 위해 정렬하는 것인데 벡터에서는 operator< 가 return val<b.val;의 결과를 반환 해야하고 우선순위 큐에서는 operator< 안의 내용이 왜 return val>b.val;의 결과를 반환 해야하는지요?
안녕하세요 영한님 강좌를 보며 예제를 따라하던중 제 프로젝트가 영한님과 다르게 실행되는것 같아 질문을 올립니다 hibernate.hbm2ddl.auto = create 인 상황에서 프로젝트를 실행하면 기존에 생성되었던 엔티티가 삭제 되지 않습니다... member와 order 엔티티만 @Entity 활성화한 상황인데요 아래 코드 올립니다.. package jpabook.jpashop.domain ; import javax.persistence. * ; import java.util.ArrayList ; import java.util. List ; @Entity public class Member { @Id @GeneratedValue (strategy = GenerationType . AUTO ) @Column (name = "MEMBER_ID" ) private Long id; private String name; private String city; private String street; private String zipcode; @OneToMany (mappedBy = "member" ) private List < Order > orders = new ArrayList <> (); public Long getId () { return id; } public void setId ( Long id ) { this .id = id ; } public String getName () { return name; } public void setName ( String name ) { this .name = name ; } public String getCity () { return city; } public void setCity ( String city ) { this .city = city ; } public String getStreet () { return street; } public void setStreet ( String street ) { this .street = street ; } public String getZipcode () { return zipcode; } public void setZipcode ( String zipcode ) { this .zipcode = zipcode ; } public List < Order > getOrders () { return orders; } public void setOrders ( List < Order > orders ) { this .orders = orders ; } } package jpabook.jpashop.domain ; import javax.persistence. * ; import java.time.LocalDateTime ; import java.util.ArrayList ; import java.util. List ; @Entity @Table (name = "ORDERS" ) public class Order { @Id @GeneratedValue (strategy = GenerationType . AUTO ) @Column (name = "ORDER_ID" ) private Long id; @ManyToOne @JoinColumn (name = "MEMBER_ID" ) private Member member; // @OneToOne // @JoinColumn(name = "DELIVERY_ID") // private Delivery delivery; // // @OneToMany(mappedBy = "order") // private List<OrderItem> orderItemList = new ArrayList<>(); private LocalDateTime orderDate; @Enumerated ( EnumType . STRING ) private OrderStatus status; public Long getId () { return id; } public void setId ( Long id ) { this .id = id ; } public Member getMember () { return member; } public void setMember ( Member member ) { this .member = member ; } public LocalDateTime getOrderDate () { return orderDate; } public void setOrderDate ( LocalDateTime orderDate ) { this .orderDate = orderDate ; } public OrderStatus getStatus () { return status; } public void setStatus ( OrderStatus status ) { this .status = status ; } } 외래키 제약조건을 삭제하는 순서와 테이블을 삭제하는 순서가 엉켜서 그런것 같은데요;; 어떤방식으로 해결해야 할지 잘 모르겠습니다.. 아래에 로그도 올려드립니다.. 답변 부탁드립니다.. Hibernate: drop table Member if exists 11월 30, 2019 11:39:55 오후 org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl getIsolatedConnection INFO: HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@3c321bdb] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode. 11월 30, 2019 11:39:55 오후 org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl handleException WARN: GenerationTarget encountered exception accepting command : Error executing DDL " drop table Member if exists" via JDBC Statement org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL " drop table Member if exists" via JDBC Statement at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67) at org.hibernate.tool.schema.internal.SchemaDropperImpl.applySqlString(SchemaDropperImpl.java:375) at org.hibernate.tool.schema.internal.SchemaDropperImpl.applySqlStrings(SchemaDropperImpl.java:359) at org.hibernate.tool.schema.internal.SchemaDropperImpl.dropFromMetadata(SchemaDropperImpl.java:241) at org.hibernate.tool.schema.internal.SchemaDropperImpl.performDrop(SchemaDropperImpl.java:154) at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDropperImpl.java:126) at org.hibernate.tool.schema.internal.SchemaDropperImpl.doDrop(SchemaDropperImpl.java:112) at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:144) at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72) at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:310) at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:939) at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:56) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54) at jpabook.jpashop.domain.JpaMain.main(JpaMain.java:8) Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Cannot drop "MEMBER" because "FKH0DB7KQR88ED8HQTCQW3JKCIA" depends on it; SQL statement: drop table Member if exists [90107-200] at org.h2.message.DbException.getJdbcSQLException(DbException.java:576) at org.h2.message.DbException.getJdbcSQLException(DbException.java:429) at org.h2.message.DbException.get(DbException.java:205) at org.h2.command.ddl.DropTable.prepareDrop(DropTable.java:98) at org.h2.command.ddl.DropTable.update(DropTable.java:124) at org.h2.command.CommandContainer.update(CommandContainer.java:198) at org.h2.command.Command.executeUpdate(Command.java:251) at org.h2.server.TcpServerThread.process(TcpServerThread.java:406) at org.h2.server.TcpServerThread.run(TcpServerThread.java:183) at java.lang.Thread.run(Unknown Source) at org.h2.message.DbException.getJdbcSQLException(DbException.java:576) at org.h2.engine.SessionRemote.done(SessionRemote.java:611) at org.h2.command.CommandRemote.executeUpdate(CommandRemote.java:237) at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:228) at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:201) at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54) ... 15 more Hibernate: drop table ORDERS if exists Hibernate: drop sequence if exists hibernate_sequence Hibernate: create sequence hibernate_sequence start with 1 increment by 1 11월 30, 2019 11:39:55 오후 org.hibernate.resource.transaction.backend.jdbc.internal.DdlTransactionIsolatorNonJtaImpl getIsolatedConnection INFO: HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@4ced35ed] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode. Hibernate: create table Member ( MEMBER_ID bigint not null, city varchar(255), name varchar(255), street varchar(255), zipcode varchar(255), primary key (MEMBER_ID) ) 11월 30, 2019 11:39:55 오후 org.hibernate.tool.schema.internal.ExceptionHandlerLoggedImpl handleException WARN: GenerationTarget encountered exception accepting command : Error executing DDL " create table Member ( MEMBER_ID bigint not null, city varchar(255), name varchar(255), street varchar(255), zipcode varchar(255), primary key (MEMBER_ID) )" via JDBC Statement org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL " create table Member ( MEMBER_ID bigint not null, city varchar(255), name varchar(255), street varchar(255), zipcode varchar(255), primary key (MEMBER_ID) )" via JDBC Statement at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67) at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlString(SchemaCreatorImpl.java:440) at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlStrings(SchemaCreatorImpl.java:424) at org.hibernate.tool.schema.internal.SchemaCreatorImpl.createFromMetadata(SchemaCreatorImpl.java:315) at org.hibernate.tool.schema.internal.SchemaCreatorImpl.performCreation(SchemaCreatorImpl.java:166) at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:135) at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:121) at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:155) at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72) at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:310) at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:467) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:939) at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:56) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54) at jpabook.jpashop.domain.JpaMain.main(JpaMain.java:8) Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "MEMBER" already exists; SQL statement: create table Member ( MEMBER_ID bigint not null, city varchar(255), name varchar(255), street varchar(255), zipcode varchar(255), primary key (MEMBER_ID) ) [42101-200] at org.h2.message.DbException.getJdbcSQLException(DbException.java:453) at org.h2.message.DbException.getJdbcSQLException(DbException.java:429) at org.h2.message.DbException.get(DbException.java:205) at org.h2.message.DbException.get(DbException.java:181) at org.h2.command.ddl.CreateTable.update(CreateTable.java:89) at org.h2.command.CommandContainer.update(CommandContainer.java:198) at org.h2.command.Command.executeUpdate(Command.java:251) at org.h2.server.TcpServerThread.process(TcpServerThread.java:406) at org.h2.server.TcpServerThread.run(TcpServerThread.java:183) at java.lang.Thread.run(Unknown Source) at org.h2.message.DbException.getJdbcSQLException(DbException.java:453) at org.h2.engine.SessionRemote.done(SessionRemote.java:611) at org.h2.command.CommandRemote.executeUpdate(CommandRemote.java:237) at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:228) at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:201) at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54) ... 15 more Hibernate: create table ORDERS ( ORDER_ID bigint not null, orderDate timestamp, status varchar(255), MEMBER_ID bigint, primary key (ORDER_ID) ) Hibernate: alter table ORDERS add constraint FKh0db7kqr88ed8hqtcqw3jkcia foreign key (MEMBER_ID) references Member 11월 30, 2019 11:39:55 오후 org.hibernate.tool.schema.internal.SchemaCreatorImpl applyImportSources INFO: HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl@6831d8fd' Hibernate: call next value for hibernate_sequence Hibernate: /* insert jpabook.jpashop.domain.Member */ insert into Member (city, name, street, zipcode, MEMBER_ID) values (?, ?, ?, ?, ?) 11월 30, 2019 11:39:55 오후 org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions WARN: SQL Error: 23505, SQLState: 23505 11월 30, 2019 11:39:55 오후 org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions ERROR: Unique index or primary key violation: "PRIMARY KEY ON PUBLIC.MEMBER(MEMBER_ID) [1, NULL, 'sdfsdf', NULL, NULL]"; SQL statement: /* insert jpabook.jpashop.domain.Member */ insert into Member (city, name, street, zipcode, MEMBER_ID) values (?, ?, ?, ?, ?) [23505-200] 11월 30, 2019 11:39:55 오후 org.hibernate.internal.ExceptionMapperStandardImpl mapManagedFlushFailure ERROR: HHH000346: Error during managed flush [org.hibernate.exception.ConstraintViolationException: could not execute statement] 11월 30, 2019 11:39:55 오후 org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl stop INFO: HHH10001008: Cleaning up connection pool [jdbc:h2:tcp://localhost/~/jpashop] Process finished with exit code 0
12:57초 코드를 입력하고 실행을 했더니 기존 코드에나왔던 결과 값만 나옵니다. 어디가 문제가 있는지 , 강좌를 다시 봐도 모르겠습니다. @EventListener @Async public void handle (ContextClosedEvent event) { System. out .println(Thread. currentThread ().toString()) ; System. out .println( "======ContextClosedEvent=====" ) ; }