小编mai*_*rgs的帖子

缓存解决方案和查询

是否有任何内存/缓存解决方案的java允许一种形式的查询缓存中对象的特定属性?

我意识到这是一个完整的数据库将被用于,但我希望能够具有数据库的查询能力的缓存的速度/性能.

java jboss caching glassfish java-ee

8
推荐指数
1
解决办法
3606
查看次数

JPA/Hibernate - 嵌入属性

我在映射类的嵌入属性时遇到了麻烦.我创建了一些类似于我试图说明的类.基本上,我有一个使用继承的@Embeddable类层次结构.顶级类"Part Number"只有一个属性,扩展类没有为"Part Number"类添加任何属性,它们只添加了一些验证/逻辑.

这就是我的意思:

部分

@Entity
@Table(name="PART")
public class Part {
    private Integer id;
    private String name;
    private PartNumber partNumber;

    @Id
    @GeneratedValue(strategy=GenerationType.SEQUENCE)
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }

    @Column(name="PART_NAME")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }

    @Embedded
    public PartNumber getPartNumber() {
        return partNumber;
    }
    public void setPartNumber(PartNumber partNumber) {
        this.partNumber = partNumber;
    }

}
Run Code Online (Sandbox Code Playgroud)

零件号

@Embeddable
public abstract class PartNumber { …
Run Code Online (Sandbox Code Playgroud)

java nhibernate hibernate jpa java-ee

8
推荐指数
1
解决办法
9566
查看次数

Oracle(旧?)加入 - 用于转换的工具/脚本?

我一直在移植oracle选择,我一直在运行很多查询,如下所示:

SELECT e.last_name,
       d.department_name
  FROM employees e,
      departments d
WHERE e.department_id(+) = d.department_id;
Run Code Online (Sandbox Code Playgroud)

...和:

SELECT last_name, 
       d.department_id
  FROM employees e, 
       departments d
 WHERE e.department_id = d.department_id(+);
Run Code Online (Sandbox Code Playgroud)

有没有转换(+)语法的所有变体的指南/教程?什么是语法甚至调用(所以我可以搜索谷歌)?

更好 ..有没有一个工具/脚本可以为我做这个转换(首选免费)?某种优化器?我有大约500个这样的查询到端口..

该标准何时逐步淘汰?任何信息表示赞赏.

sql database oracle plsql outer-join

7
推荐指数
1
解决办法
7865
查看次数

JNA加载库

我有两个库,一个带有Ada对象,另一个带有C++对象(我没有很多控件可以在哪里找到)

Ada的东西引用了C的东西,反之亦然......

此符号位于libIPCAda.so中:ipc_manager_shutdown_c

此符号位于libIPCC.so中:stream_buffer_header_size

当我做这些JNA电话时:

   CLibrary INSTANCE8 = (CLibrary)
   Native.loadLibrary("IPCAda", //  <<< our library goes here
                      CLibrary.class);

   CLibrary INSTANCE9 = (CLibrary)
   Native.loadLibrary("IPCC", //  <<< our library goes here
                      CLibrary.class);
Run Code Online (Sandbox Code Playgroud)

我明白了:

ld.so.1: java: fatal: relocation error: file <<my directory>>/lib/libIPCAda.so: symbol stream_buffer_header_size: referenced symbol not found
Run Code Online (Sandbox Code Playgroud)

当我做这些JNA调用时:

   CLibrary INSTANCE9 = (CLibrary)
   Native.loadLibrary("IPCC", //  <<< our library goes here
                      CLibrary.class);

   CLibrary INSTANCE8 = (CLibrary)
   Native.loadLibrary("IPCAda", //  <<< our library goes here
                      CLibrary.class);
Run Code Online (Sandbox Code Playgroud)

我明白了:

Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load …
Run Code Online (Sandbox Code Playgroud)

c++ java java-native-interface shared-libraries jna

7
推荐指数
1
解决办法
3979
查看次数

从符号到地形的世界风线

Worldwind的Point PlaceMark可渲染具有通过调用setLineEnabled从地标到地形的一条线,如下截图所示:

在此输入图像描述

我正在尝试做的是添加一条这样的线,它也适用于可渲染的战术符号.我的第一个想法是从PointPlacemark可渲染中借用逻辑来执行此操作,并将其添加到AbstractTacticalSymbol可渲染.我试过了,到目前为止我还没有成功.

这是我到目前为止所做的:

  1. 将此添加到OrderedSymbol类:

    public Vec4 terrainPoint;
    
    Run Code Online (Sandbox Code Playgroud)
  2. 更新了computeSymbolPoints以计算terrainPoint

    protected void computeSymbolPoints(DrawContext dc, OrderedSymbol osym)
    {
        osym.placePoint = null;
        osym.screenPoint = null;
        osym.terrainPoint = null;
        osym.eyeDistance = 0;
    
        Position pos = this.getPosition();
        if (pos == null)
            return;
    
        if (this.altitudeMode == WorldWind.CLAMP_TO_GROUND || dc.is2DGlobe())
        {
            osym.placePoint = dc.computeTerrainPoint(pos.getLatitude(), pos.getLongitude(), 0);
        }
        else if (this.altitudeMode == WorldWind.RELATIVE_TO_GROUND)
        {
            osym.placePoint = dc.computeTerrainPoint(pos.getLatitude(), pos.getLongitude(), pos.getAltitude());
        }
        else // Default to ABSOLUTE
        {
            double height = pos.getElevation() …
    Run Code Online (Sandbox Code Playgroud)

java opengl jogl worldwind

7
推荐指数
1
解决办法
478
查看次数

WorldWind PointPlacemark标题

在NASA WorldWind Java中,我使用PointPlacemark来表示图像,因为无论缩放级别如何,它都保持相同的大小.问题是我想在Point Placemark上设置标题,即使相机倾斜,它也会保持在指南针上.它在查看一个倾斜的地球仪时完全按照我想要的方式工作,但当我倾斜时,地标继续面向屏幕,而不是与地球一起倾斜,这会导致它变得奇怪.

这是一个GIF,说明了我所看到的:https: //giphy.com/embed/3o7WIqZUceR8xh6BOg

我希望点地标图像保持在相对于地球的标题上,即使在倾斜时 - 因此当视图倾斜时图像基本上"平坦化",而不管缩放级别如何仍保持相同的大小.

这是我正在使用的代码片段.我正在设置attrs.setHeadingReference(AVKey.RELATIVE_TO_GLOBE); 在关联的PointPlacemarkAttributes上.在此示例中,我将标题设置为135度.

import gov.nasa.worldwind.WorldWind;
import gov.nasa.worldwind.avlist.AVKey;
import gov.nasa.worldwind.geom.Position;
import gov.nasa.worldwind.layers.RenderableLayer;
import gov.nasa.worldwind.render.Offset;
import gov.nasa.worldwind.render.PointPlacemark;
import gov.nasa.worldwind.render.PointPlacemarkAttributes;

public class Placemarks extends ApplicationTemplate {
    public static class AppFrame extends ApplicationTemplate.AppFrame {

        public AppFrame() {
            super(true, true, false);

            final RenderableLayer layer = new RenderableLayer();

            PointPlacemark pp = new PointPlacemark(Position.fromDegrees(28, -102, 30000));
            pp.setLabelText("Airplane");
            pp.setLineEnabled(false);
            pp.setAltitudeMode(WorldWind.ABSOLUTE);
            PointPlacemarkAttributes attrs = new PointPlacemarkAttributes();
            attrs.setImageAddress("images/airplane.png");
            attrs.setScale(0.05);
            attrs.setImageOffset(Offset.CENTER);

            //Point to 135.0
            attrs.setHeading(135.0);
            attrs.setHeadingReference(AVKey.RELATIVE_TO_GLOBE);

            pp.setAttributes(attrs);

            layer.addRenderable(pp);

            // Add the …
Run Code Online (Sandbox Code Playgroud)

java opengl jogl worldwind

7
推荐指数
2
解决办法
549
查看次数

在视图上执行触发器?

我不太熟悉数据库触发器和/或视图.我目前正在使用PostgreSQL和HSQL; 虽然数据库不是太重要.我只是想知道是否有任何数据库提供这样的东西:

我有一个这样的(示例)表:

CREATE TABLE DUMMY_TABLE (ID INTEGER, NUMBER INTEGER);
Run Code Online (Sandbox Code Playgroud)

我创建了一个这样的视图:

CREATE VIEW DUMMY_VIEW AS SELECT * FROM DUMMY_TABLE WHERE NUMBER > 5;
Run Code Online (Sandbox Code Playgroud)

我插入了几个实体:

INSERT INTO DUMMY_TABLE VALUES(1,2);
INSERT INTO DUMMY_TABLE VALUES(1,10);
Run Code Online (Sandbox Code Playgroud)

因此,当我打电话时,DUMMY_VIEW只包含VALUES(1,10)

SELECT * FROM DUMMY_VIEW
Run Code Online (Sandbox Code Playgroud)

所以现在我要做的是为DUMMY_VIEW添加一个触发器,只要插入NUMBER> 5的实体,就会调用该触发器.

我曾尝试将触发器直接添加到HSQL和PostgreSQL中的DUMMY_VIEW; 但他们说触发器无法添加到视图中.

这是(或功能相似的解决方案)可能吗?

postgresql triggers view hsqldb

6
推荐指数
2
解决办法
1万
查看次数

Persistence.xml和OSGi(Equinox)

我目前正在测试使用OSGi.我通过Eclipse运行它.我希望将我的DAO层作为OSGi解决方案的一部分,但我的第一个绊脚石是这个错误:

Jun 29, 2009 6:12:37 PM org.hibernate.cfg.annotations.Version <clinit>
INFO: Hibernate Annotations 3.3.0.GA
Jun 29, 2009 6:12:37 PM org.hibernate.ejb.Version <clinit>
INFO: Hibernate EntityManager 3.3.0.GA
Jun 29, 2009 6:12:37 PM org.hibernate.ejb.Ejb3Configuration configure
INFO: Could not find any META-INF/persistence.xml file in the classpath
Run Code Online (Sandbox Code Playgroud)

我已经尝试将persistence.xml文件放在很多不同的地方,但无济于事. 关于我做错了什么的任何想法?

有没有办法手动加载persistence.xml?

该激活剂是这样的:

package com.activator;


public class PersistenceActivator implements BundleActivator {

    @Override
    public void start(BundleContext arg0) throws Exception {

        EntityManagerFactory emf = Persistence
                .createEntityManagerFactory("postgres");
        EntityManager em = emf.createEntityManager();

        SimpleDaoImpl dao = new SimpleDaoImpl();
        dao.setEntityManager(em);

    }

    @Override
    public …
Run Code Online (Sandbox Code Playgroud)

java osgi jpa java-ee equinox

6
推荐指数
2
解决办法
1万
查看次数

使用TransferHandler拖动JLabel(拖放)

我正在使用TransferHandler将数据从JPanel传递到JTextArea作为JLabel(单击左侧面板中的某个位置以创建要拖动的JLabel)

数据的传输工作正常,但我也想"显示"JLabel被拖动与鼠标指针一起.

如果你评论出来

dropLabel.setTransferHandler(new TransferHandler("text"));

dropLabel.getTransferHandler().exportAsDrag(dropLabel, e,
            TransferHandler.COPY);
Run Code Online (Sandbox Code Playgroud)

你会看到我希望它看起来如何.(但当然数据不会被转移).

如何让传输工作和JLabel跟随鼠标光标?

这是代码:

import java.awt.*;
import java.awt.datatransfer.Transferable;
import java.awt.event.*;

import javax.swing.*;
import javax.swing.border.Border;

public class DragTest extends JFrame implements MouseMotionListener,
        MouseListener {

    private JPanel leftPanel = new JPanel(null);
    private JPanel rightPanel = new JPanel(null);
    private JLabel dragLabel = new JLabel("drop");
    private final JWindow window = new JWindow();
    JLabel dropLabel;

    public DragTest() {
        this.setLayout(new GridLayout(1, 2));

        leftPanel.setBorder(BorderFactory.createLineBorder(Color.black));
        rightPanel.setBorder(BorderFactory.createLineBorder(Color.black));
        this.add(leftPanel);
        this.add(rightPanel);
        leftPanel.addMouseListener(this);
        leftPanel.addMouseMotionListener(this);

        JTextArea area = new JTextArea();

        rightPanel.setLayout(new GridLayout(1, 1));
        rightPanel.add(area);

        dragLabel.setFont(new Font("Serif", …
Run Code Online (Sandbox Code Playgroud)

java swing drag-and-drop jpanel

6
推荐指数
1
解决办法
1万
查看次数

Worldwind PointPlacemark Pitch

我试图弄清楚为什么PointPlacemarkAttributes中的setPitch似乎无法正常工作.

我相信PointPlacemark.java中的这个JOGL代码是出错的地方:

        Double heading = getActiveAttributes().getHeading();
        Double pitch = getActiveAttributes().getPitch();

        // Adjust heading to be relative to globe or screen
        if (heading != null)
        {
            if (AVKey.RELATIVE_TO_GLOBE.equals(this.getActiveAttributes().getHeadingReference()))
                heading = dc.getView().getHeading().degrees - heading;
            else
                heading = -heading;
        }

        // Apply the heading and pitch if specified.
        if (heading != null || pitch != null)
        {
            gl.glTranslated(xscale / 2, yscale / 2, 0);
            if (pitch != null)
                gl.glRotated(pitch, 1, 0, 0);
            if (heading != null)
                gl.glRotated(heading, 0, 0, …
Run Code Online (Sandbox Code Playgroud)

java geometry jogl worldwind

6
推荐指数
1
解决办法
202
查看次数