我有一个管理3个数据库的应用程序.我在seam框架上使用了带JPA的hibernate.
所以我有一个persitence.xml文件,有三个像这样的persitence-unit(我删除了db2和db3的属性):
<persistence-unit name="db1" transaction-type="JTA" >
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>db1source</jta-data-source>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.Oracle10gDialect" />
<property name="hibernate.connection.driver_class"
value="oracle.jdbc.driver.OracleDriver" />
<property name="hibernate.hbm2ddl.auto" value="validate" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.default_schema" value="SI_TEC" />
<property name="hibernate.validator.apply_to_ddl" value="false" />
<property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.WeblogicTransactionManagerLookup" />
</properties>
</persistence-unit>
<persistence-unit name="db2" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>d2source</jta-data-source>
</persistence-unit>
<persistence-unit name="db3" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>d3source</jta-data-source>
</persistence-unit>
Run Code Online (Sandbox Code Playgroud)
在我的seam components.xml文件中,我使用我的hibernate配置创建了3个managed-persistence-context来映射seam.
最后,我有几个实体,我的问题就在这里.我需要在db2和db3中的其他实体中保留一些实体.所以数据库模式是不同的,当我部署我的应用程序时,我收到此错误:
org.hibernate.HibernateException: Missing table: PORTAILPERMISSION
at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1113)
at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:139)
at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:349)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1327)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
Truncated. see log file for complete stacktrace
Run Code Online (Sandbox Code Playgroud)
因为,db2中不存在表PORTAILPERMISSION. …
简单地说,我不能:
HTTPS推送
SSH推送
我是Java Threads和同步的新手.
让我们说:
public class MyClass(){
public synchronized void method1(){
//call method2();
}
public synchronized void method2(){};
}
Run Code Online (Sandbox Code Playgroud)
当我同步一个method1()实例对象时它意味着什么?因此,当一个线程在尝试访问时获取锁定时synchronized method1(),是否会阻止其他线程synchronized method2()从同一个对象访问另一个线程?
让我们说一个线程在访问method1()时获取一个锁,但是让我们说这也是method1()一个调用.这有可能吗?我的意思是有任何规则可以阻止呼叫吗?method2()synchronizedmethod1()method2()
提前致谢.
显然在实体bean中使用无状态EJB bean会有异味,但请考虑如下方案并告诉我您是否知道更好的解决方案:
InvoiceTemplate带有字段的实体BeanNextInvoiceDateNextInvoiceDate是一个复杂的过程,应该在InvoiceTemplate课外进行NextInvoiceDate应该每次都更新InvoiceTemplate存储到db现在我有关于实体bean NextInvoiceDate中的@PrePersist @PreUpdatemethon 生成的逻辑InvoiceTemplate.逻辑变得越来越复杂,我想将它移到InvoiceTemplate实体bean之外.它在我看来应该有一个服务来计算NextInvoiceDate.但那么从内部调用这项服务是否正确InvoiceTemplate?
我正在使用multipart将文件上传到服务器URLLoader.我可以上传文件.我试图在URLLoader上侦听progress事件,但它只在上传的最后触发.如何通过上传更加一致地获得进度事件?
从Spring API,我明白@InitBinder用于初始化一些绑定规则..
在petclinic的例子中为什么我们有setdisallowed("id")?当id没有显示在表单上时?
@InitBinder
public void setAllowedFields(WebDataBinder dataBinder) {
dataBinder.setDisallowedFields("id");
}
Run Code Online (Sandbox Code Playgroud)
id字段没有显示在网页上,那么为什么我们使用上面的代码呢?
我们可以有这样的事情:
@InitBinder
public void setAllowedFields(WebDataBinder dataBinder) {
dataBinder.setDisallowedFields("FirstName");
}
Run Code Online (Sandbox Code Playgroud)
根据上面的代码,虽然用户在表单上输入,但不会设置所有者对象的名字字段?那是对的吗?
An Id作为Url参数传入.我试着确保它id是一个数字.如果没有重定向到主页面
if(facilityId != null){
try{
Long.parseLong(facilityId);
}catch(NumberFormatException e){
try {
FacesContext.getCurrentInstance().getExternalContext().redirect("DisplayList.jsf");
} catch (IOException ex) {}
}
facility = documentSBean.findFacilityById(Long.parseLong(facilityId));
...
}
Run Code Online (Sandbox Code Playgroud)
所以,如果我传入这样的id
www....?facilityId=3?sdfasfda
Run Code Online (Sandbox Code Playgroud)
我发现这3?sdfasfda不是一个数字,并且转到redirect语句,但它没有正确地重定向,它执行下一对试图转换3?sdfasfda为Long的行,因此产生NumberFormatException.那么有没有办法立即强制重定向,或者是否有其他方法来解决这个问题.希望有一个else后catch:D:D.上面的代码在我的@PostConstruct init()方法中
<beans default-autowire="byType />
Run Code Online (Sandbox Code Playgroud)
表示如果不超过1个具有所需类型的bean,则bean的所有字段将自动注入依赖项.
问题是当使用注释时这是如何工作的,它是否有效.
我的测试显示,即使我使用
@Resource(name="someConcreteFoo")
private Foo foo;
Run Code Online (Sandbox Code Playgroud)
上下文尝试按类型自动装配字段,如果有多个实现,则失败Foo.因此,对于我所看到的,default-autowire不会与注释混在一起.我在文档中找不到任何具体内容.
扩展问题 - 当使用xml-only时,spring如何使用default-autowiring进行操作.即如果你有的话<property>.属性注入是否覆盖默认值(应该是).
我可以做更多的测试,但我更喜欢某些引用确认的行为.任何见解?
Javadocs说:
返回此Method的哈希码.哈希码被计算为底层方法声明类名和方法名的哈希码的异或.
这个描述中明显缺少的是Method的参数类型的类型 - 这是否意味着同一个类上具有相同名称但参数不同的两个方法会有相同的hashCode()?
假设我有两个子域:
产品介绍:
products.example.com
Run Code Online (Sandbox Code Playgroud)
用户:
users.example.com
Run Code Online (Sandbox Code Playgroud)
如何设置单个Spring MVC应用程序以不同方式处理每个域(在我的情况下,我想根据用户从哪个子域使用不同的数据库)?
java ×6
spring ×3
jpa ×2
spring-mvc ×2
apache-flex ×1
database ×1
ejb-3.0 ×1
file-upload ×1
git ×1
github ×1
hashcode ×1
hibernate ×1
jsf ×1
redirect ×1
reflection ×1
seam ×1
subdomain ×1
urlloader ×1