我有一个带有生成ID的HSQLDB数据库,我希望自动递增值始终高于100,000.HSQLDB可以实现吗?这对任何数据库都可以吗?
性能是关键:在数据库内部级联删除/更新还是让 Hibernate/JPA 处理它更好?
如果级联在 DBMS 内部,这会影响查询数据的能力吗?
如果这很重要,我正在使用 HSQLDB。
我使用hibernate作为我的ORM解决方案,使用EHCache作为二级(读写)缓存.
我的问题是:是否可以直接访问二级缓存?
我想访问这个:http://www.hibernate.org/hib_docs/v3/api/org/hibernate/cache/ReadWriteCache.html
如何访问Hibernate正在使用的相同ReadWriteCache?
我有一些我正在做的直接/自定义JDBC插入,我想自己将这些对象添加到二级缓存中.
我使用Hibernate + JPA作为我的ORM解决方案.
我使用HSQL进行单元测试,将PostgreSQL用作真正的数据库.
我希望能够将Postgres的本机UUID类型与Hibernate一起使用,并在其字符串表示中使用UUID和HSQL进行单元测试(因为HSQL没有UUID类型).
我正在使用具有Postgres和HSQL单元测试的不同配置的持久性XML.
这是我如何让Hibernate"看到"我的自定义UserType:
@Id
@Column(name="UUID", length=36)
@org.hibernate.annotations.Type(type="com.xxx.UUIDStringType")
public UUID getUUID() {
return uuid;
}
public void setUUID(UUID uuid) {
this.uuid = uuid;
}
Run Code Online (Sandbox Code Playgroud)
这很有效.但我需要的是能够在XML中替换注释的"com.xxx.UUIDStringType"部分,或者从可以在不重新编译的情况下更改的属性文件.
有任何想法吗?
根据您的经验,Hibernate的一些优秀性能调整是什么?我的意思是插入/更新和查询.
我最近发现了消息选择器
@ActivationConfigProperty(
propertyName="messageSelector",
propertyValue="Fragile IS TRUE")
Run Code Online (Sandbox Code Playgroud)
我的问题是:如何在运行时使选择器动态化?
让我们说消费者决定他们只想要属性为"Fragile IS FALSE"的消息
消费者可以在不重新部署MDB的情况下以某种方式更改选择器吗?
注意:我使用的是Glassfish v2.1
我需要一个满足这些要求的java数据结构/解决方案.什么最适合这些?
1)必须保留对象的插入顺序
2)对象必须是唯一的(这些是由UUID唯一标识的数据库对象).
3)如果添加了具有相同ID的较新对象,则应覆盖/删除旧版本的对象
4)许多线程都应该可以访问解决方案.
5)当读取/使用添加到Structure的第一个对象时,应该从数据结构中删除它
我最近在工作中遇到了一些代码(重新创建类似于我正在处理的代码),类似于下面的代码
有没有办法可以重新编写下面的代码来使用一个数据结构(考虑到性能)?
这里有一些代码来说明我的意思:
public class ObjectMapper {
private Map<UUID,Integer> uuidMap;
private Map<Integer,UUID> indexMap;
public ObjectMapper(){
uuidMap = new HashMap<UUID,Integer>();
indexMap = new HashMap<Integer,UUID>();
}
public void addMapping(int index, UUID uuid){
uuidMap.put(uuid, index);
indexMap.put(index, uuid);
}
.
.
.
public Integer getIndexByUUID(UUID uuid){
return uuidMap.get(uuid);
}
public UUID getUUIDByIndex(Integer index){
return indexMap.get(index);
}
}
Run Code Online (Sandbox Code Playgroud) 我有两个线程,我想确保我在 LinkedBlockingQueue 上正确执行同步。这是正确的吗?或者 (messageToCommsQueue) 上的显式同步不需要吗?
宣言:
private LinkedBlockingQueue<BaseMessage> messagesToCommsQueue;
Run Code Online (Sandbox Code Playgroud)
方法一:
private void startOperationModeStatusMessageExecutor() {
ScheduledExecutorService operationModeStatusExecutor = Executors.newSingleThreadScheduledExecutor();
operationModeStatusExecutor.scheduleAtFixedRate((new Runnable() {
@Override
public void run() {
ModeStatusMessage commsOperateMsg;
commsOperateMsg = MessageFactory.getModeStatusMessage(status.ordinal());
synchronized (messagesToCommsQueue) {
messagesToCommsQueue.add(commsOperateMsg);
}
}
}), 0, 10, TimeUnit.SECONDS);
}
Run Code Online (Sandbox Code Playgroud)
方法二:
Executor commsSenderExecutor = Executors.newSingleThreadExecutor();
commsSenderExecutor.execute(new Runnable() {
@Override
public void run() {
while (getStatus().equals(ModeStatus.INITIATE) || getStatus().equals(ModeStatus.OPERATE)) {
BaseMessage m = null;
try {
synchronized (messagesToCommsQueue) {
m = messagesToCommsQueue.take();
}
} catch (InterruptedException e) {
// TODO …Run Code Online (Sandbox Code Playgroud) 我正在使用Java NASA WorldWind,我有两个不同高度和位置的对象.
如何在考虑到地球曲率的情况下找到物体之间的仰角?
这张图片说明了(显然不按比例)我正在尝试做的事情:

物体A高出地面50英尺,物体B高出地面500英尺.我怎样才能找到角度X,考虑到地球的曲率?
java ×7
hibernate ×4
hsqldb ×3
java-ee ×3
jpa ×3
sql ×3
annotations ×1
caching ×1
cascade ×1
collections ×1
concurrency ×1
ehcache ×1
executor ×1
geospatial ×1
identity ×1
jboss-mdb ×1
jms ×1
math ×1
oop ×1
performance ×1
primary-key ×1
uuid ×1
worldwind ×1