`
jhyimu2005
  • 浏览: 185829 次
  • 性别: Icon_minigender_2
  • 来自: 苏州
社区版块
存档分类
最新评论

AnnotationException: Cannot find the expected secondary table

阅读更多
今天遇到一个比较奇怪的问题就是表明明就存在,却总是抛出异常说表不存在,其异常代码如下:
Caused by: org.hibernate.AnnotationException: Cannot find the expected secondary table: no bio_experiment_protocol available for com.founder.cims.bio.model.Protocol
	at org.hibernate.cfg.Ejb3Column.getJoin(Ejb3Column.java:293)
	at org.hibernate.cfg.Ejb3Column.getTable(Ejb3Column.java:272)
	at org.hibernate.cfg.AnnotationBinder.bindManyToOne(AnnotationBinder.java:1946)
	at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:1368)
	at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:754)
	at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:534)
	at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:286)
	at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1148)
	at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:673)
	at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
	... 59 more



在项目中我用的一对多的双向关联,并且用的是中间表来进行两个表关联的。其关联关系如下:
@Entity
@Table(name = "BIO_NOTEBOOK")
@SequenceGenerator(name = "BIO_NOTEBOOK_SQ", sequenceName = "BIO_NOTEBOOK_SQ",
		allocationSize = 1, initialValue = 1)
public class Notebook implements Serializable{
	
	private static final long serialVersionUID = 7346303079987267177L;
	
	private Integer id;
	private String name;
	private String description;
	private int staus;
	private String author;
	
	
	private Experiment experiment;

        @ManyToOne(fetch = FetchType.LAZY, targetEntity = Experiment.class)
	@JoinTable(name = "BIO_EXPERIMENT_NOTEBOOK",
			joinColumns = {@JoinColumn(name = "NOTEBOOK_ID")},
			inverseJoinColumns = {@JoinColumn(name = "EXPERIMENT_ID")}
			)
        public Experiment getExperiment() {
		return experiment;
	}

	public void setExperiment(Experiment experiment) {
		this.experiment = experiment;
	}

一对多的那端
@Entity
@Table(name = "BIO_EXPERIMENT")
@SequenceGenerator(name = "BIO_EXPERIMENT_SQ", sequenceName = "BIO_EXPERIMENT_SQ", allocationSize = 1, initialValue = 1)
public class Experiment implements Serializable{
	
	private static final long serialVersionUID = 1315584437277200383L;
	
	private Integer id;
	private Study study;
	private String type;
	private Integer status;
	private InVivoExperiment invivoExperiment;
	private InVitroExperiment invitroExperiment;
	private DmpkExperiment dmpkExperiment;
	
	private Set<Notebook> notebooks;

        @OneToMany(mappedBy = "experiment")
	public Set<Notebook> getNotebooks() {
		return notebooks;
	}

	public void setNotebooks(Set<Notebook> notebooks) {
		this.notebooks = notebooks;
	}


当我把注解写到变量声明的上面就正确了即:
@Entity
@Table(name = "BIO_NOTEBOOK")
@SequenceGenerator(name = "BIO_NOTEBOOK_SQ", sequenceName = "BIO_NOTEBOOK_SQ",
		allocationSize = 1, initialValue = 1)
public class Notebook implements Serializable{
	
	private static final long serialVersionUID = 7346303079987267177L;
	
	private Integer id;
	private String name;
	private String description;
	private int staus;
	private String author;
	
	@ManyToOne(fetch = FetchType.LAZY, targetEntity = Experiment.class)
	@JoinTable(name = "BIO_EXPERIMENT_NOTEBOOK",
			joinColumns = {@JoinColumn(name = "NOTEBOOK_ID")},
			inverseJoinColumns = {@JoinColumn(name = "EXPERIMENT_ID")}
			)
	private Experiment experiment;

        public Experiment getExperiment() {
		return experiment;
	}

	public void setExperiment(Experiment experiment) {
		this.experiment = experiment;
	}

目前我也不知道是什么原因,有哪位知道的话可以给留言呀,期待中,谢谢!
分享到:
评论

相关推荐

    Microsoft Excel File Format

    微软Excel文件格式是电子表格软件Microsoft Excel使用的数据存储格式,其版本涵盖了从Excel 2.0到Excel 2003的多个版本。这一文件格式详细描述了Excel文档的基本结构,包括工作簿(Workbook)和工作表(Worksheet)...

    OSError: no library called "cairo" was found GTK++ windows 安装包

    cannot load library 'libcairo.so.2': libcairo.so.2: cannot open shared object file: No such file or directory cannot load library 'libcairo.2.dylib': libcairo.2.dylib: cannot open shared object file: ...

    delphi问题常见解决

    1. **“statement expected but procedure found”**:这个错误提示表明在编译器尝试找到一个语句的地方,它却找到了一个过程(Procedure)的定义。这通常意味着你在某个过程或函数的定义中忘记了关闭的`end`关键字...

    shell脚本报错:"[: =: unary operator expected"解决办法

    在使用Shell脚本编程时,有时我们可能会遇到一个常见的错误提示:“[: =: unary operator expected”。这个错误通常出现在我们尝试进行条件判断时,尤其是当我们在`if`语句中使用`[ ... ]`或者`[[ ... ]]`进行比较...

    hbase 启动regionserver日志报错: Wrong FS: hdfs:// .regioninfo, expected: file:///

    NULL 博文链接:https://bnmnba.iteye.com/blog/2322332

    HTK3.4的.MKF 文件.zip

    window编译HTK3.4时会报错:htk_htklib_nt.mkf(6):fatalerrorU1035:syntaxerror:expected‘:’or‘=’separatorStop.这主要是由于这个文件格式编码的问题,只需下载然后替换相应的mkf文件,重新编译即可。目前发现HTK...

    shell脚本报错:”[: =: unary operator expected”解决办法

    shell脚本报错:”[: =: unary operator expected”解决办法  在匹配字符串相等时,我用了类似这样的语句: if [ $STATUS == OK ]; then echo OK fi  在运行时出现了 [: =: unary operator expected 的错误,就...

    calico.yaml

    calico集群模式下的yaml配置。sed -i "s#192\.168\.0\.0/16#${POD_SUBNET}#" calico.yaml

    http-error-parse:NodeJS HTTP 错误解析。 给定一个错误堆栈对象,获取一条消息和_或相关的 HTTP 响应代码(404、400、401 等)

    http-error-parse 给定错误堆栈对象,获取一条消息和/或关联的HTTP响应代码(404、400、401等) 我创建它是为了与 express.js 一起使用,但它应该能够处理不同类型的错误,并智能地返回 HTTP 响应代码和简单的字符串...

    SDK16.0.0的使用说明.txt

    Nordic SDK16.0.0使用中遇到的问题,8.27.0 Pack问题,编译找不到nrf_erratas.h问题

    KEIL编译错误信息

    Cannot read or write variables of this type (error64):** - **含义:** 无法读写该类型的变量。 - **解决方法:** 确保变量类型是可读写的。 **63. Pointer variable expected (error65):** - **含义:** 期望...

    WhatsApp Unknown 2020-11-27 at 16.28.18_dbfhff.fgchhdf_www.baidu

    imagem end for website dom pelo minoxidil

    Parasoft Handbook

    Verification ensures that the request and response match the expected outcomes. To verify: 1. **Step 1**: Define expected results for the request and response. 2. **Step 2**: Use checkpoints or ...

    PointNet中出现错误的小文件render_balls_so.dll

    解决复现 PointNet 中出现的【dll = np.ctypeslib.load_library(‘render_balls_so’, ‘.’) OSError: no file with expected extension:】问题。只需要替换原作者代码中的文件就可以。

    Codewarrior编译出现的错误以及解决方法

    Codewarrior是一款由Metrowerks公司开发的集成开发环境,主要针对Motorola/Freescale的微处理器进行软件开发。文档《单片机技术初步实践》提供了有关Codewarrior在编译过程中可能遇到的C语言语法错误及其解决方法。...

    expected:C ++ 111417标准

    std::expected单个标头实现,带有功能样式的扩展名。 lang + GCC: MSVC: 在和上可用。 建议使用作为表示对象的首选方法,该对象将具有预期值或意外值,以提供有关某些原因的信息。 不幸的是,将许多可能失败的...

    HyperledgerFabric问题及解决.txt

    UTC [main] main -&gt; ERRO 001 Cannot run peer because error when setting up MSP from directory Error:can't read the block:&{SERVICE_UNAVAILABLE} Error:Error endorsing chaincode:rpc error:code = ...

    keil常见错误.pdf

    keil常见错误 main.c(35): warning: #128-D: loop is not reachable from preceding code main.c(54): warning: #1-D: last line of file ends without a newline initSpi.c(6): error: #268: declaration may not ...

Global site tag (gtag.js) - Google Analytics