我已经在DB2数据库中创建了视图,并且我正在尝试使用jpa 2.0从这些视图中获取数据但是当我运行ma服务器时我有这个:
May 18, 2017 6:24:34 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.3.8.Final}
May 18, 2017 6:24:34 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
May 18, 2017 6:24:34 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
May 18, 2017 6:24:34 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.5.Final}
May 18, 2017 6:24:35 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.DB2400Dialect
May 18, 2017 6:24:35 PM org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation
INFO: HHH000423: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4
May 18, 2017 6:24:35 PM org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
INFO: HHH000397: Using ASTQueryTranslatorFactory
May 18, 2017 6:24:35 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: HHH000228: Running hbm2ddl schema update
May 18, 2017 6:24:35 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: HHH000102: Fetching database metadata
May 18, 2017 6:24:35 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: HHH000396: Updating schema
May 18, 2017 6:24:35 PM org.hibernate.tool.hbm2ddl.DatabaseMetadata getTableMetadata
INFO: HHH000262: Table not found: dossier
May 18, 2017 6:24:36 PM org.hibernate.tool.hbm2ddl.DatabaseMetadata getTableMetadata
INFO: HHH000262: Table not found: provision
May 18, 2017 6:24:36 PM org.hibernate.tool.hbm2ddl.DatabaseMetadata getTableMetadata
INFO: HHH000262: Table not found: dossier
May 18, 2017 6:24:36 PM org.hibernate.tool.hbm2ddl.DatabaseMetadata getTableMetadata
INFO: HHH000262: Table not found: provision
May 18, 2017 6:24:36 PM org.hibernate.tool.hbm2ddl.DatabaseMetadata getTableMetadata
INFO: HHH000262: Table not found: dossier
May 18, 2017 6:24:36 PM org.hibernate.tool.hbm2ddl.DatabaseMetadata getTableMetadata
INFO: HHH000262: Table not found: provision
May 18, 2017 6:24:36 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
ERROR: HHH000388: Unsuccessful: create table dossier (num_dossier varchar(255) not null, nature varchar(255), num_cheque varchar(255), patente varchar(255), personne varchar(255), primary key (num_dossier))
May 18, 2017 6:24:36 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
ERROR: [SQL0204] FNAC de type *LIB dans QSYS non trouvé.
May 18, 2017 6:24:36 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
ERROR: HHH000388: Unsuccessful: create table provision (id varchar(255) not null, annee integer not null, imp_capital integer not null, imp_int_ht integer not null, imp_int_ttc integer not null, mois integer not null, mte_prov_rest integer not null, nbr_imp integer not null, typ_dossier varchar(255), dossier varchar(255), primary key (id))
May 18, 2017 6:24:36 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
ERROR: [SQL0204] FNAC de type *LIB dans QSYS non trouvé.
May 18, 2017 6:24:36 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
ERROR: HHH000388: Unsuccessful: alter table provision add constraint FK_2lk1jgv8il1kjgiv25veiiy6m foreign key (dossier) references dossier
May 18, 2017 6:24:36 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
ERROR: [SQL0204] PROVISION de type *FILE dans FNAC non trouvé.
May 18, 2017 6:24:36 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: HHH000232: Schema update complete
May 18, 2017 6:24:36 PM org.springframework.web.context.ContextLoader initWebApplicationContext
INFO: Root WebApplicationContext: initialization completed in 1950 ms
May 18, 2017 6:24:36 PM com.sun.faces.config.ConfigureListener contextInitialized
INFO: Initializing Mojarra 2.2.8 ( 20140814-1418 https://svn.java.net/svn/mojarra~svn/tags/2.2.8@13507) for context '/FNACStatistic'
May 18, 2017 6:24:36 PM com.sun.faces.config.ConfigureListener$WebConfigResourceMonitor$Monitor <init>
INFO: Monitoring jndi:/localhost/FNACStatistic/WEB-INF/faces-config.xml for modifications
May 18, 2017 6:24:36 PM org.primefaces.webapp.PostConstructApplicationEventListener processEvent
INFO: Running on PrimeFaces 5.1
May 18, 2017 6:24:36 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
May 18, 2017 6:24:36 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
May 18, 2017 6:24:36 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/11 config=null
May 18, 2017 6:24:36 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 3030 ms
@Entity
public class Provision implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Getter
private String id;
@Getter
private int annee;
@Getter
private int mois;
@Getter
private int mteProvRest;
@Getter
private int impCapital;
@Getter
private int impIntHt;
@Getter
private int impIntTtc;
@Getter
private String typDossier;
@Getter
private int nbrImp;
@OneToOne
@JoinColumn(name="dossier")
@Getter
private Dossier dossier;
@Entity
public class Dossier implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Getter
private String numDossier;
@Getter
private String personne;
@Getter
private String numCheque;
@Getter
private String nature;
@Getter @Setter
private String patente;
我知道JPA处理数据库视图与表相同,但我无法弄清楚问题的来源。
答案 0 :(得分:0)
您的hibernate配置(hbm2ddl:update)正在尝试创建您的视图。 实体是否正确映射视图? (相同的视图名称,相同的字段?)
此外,您应该在课程中添加@Immutable。这将阻止任何更新。 (https://docs.jboss.org/hibernate/orm/5.2/javadocs/org/hibernate/annotations/Immutable.html)
答案 1 :(得分:0)
我确实找到了问题的来源:我忘了在连接网址上指定数据库的名称。所以它现在有效