LWJGL 3 Can’t load uniforms to shaders

I can’t get uniforms work with my buffer. This has been happening since I changed to LWJGL 3.

//Java code

FloatBuffer transformationMatrix = BufferUtils.createFloatBuffer(16);

float[] matrixData = {  

    1, 0, 0, 0,   //This matrix data should keep 
    0, 1, 0, 0,   //everything in their original position.
    0, 0, 1, 0,  
    0, 0, 0, 1

};

transformationMatrix.put(matrixData);
transformationMatrix.flip();

//transformationUniformLocation is 0 as told by glGetUniformLocation()

GL20.glUniformMatrix4fv(transformationUniformLocation, false, transformationMatrix);

Shader:

#version 430 core

in vec3 position

uniform mat4 transformationMatrix;

void main(void) {

    //gl_Position = vec4(position, 1.0); This works but I need transformation matrix.

    gl_Position = transformationMatrix * vec4(position, 1.0); //This doesn't work!

}

I have tried few if statements in shader and it looks like transformationMatrix is empty. One weird thing is also that if I add this before gl_Position then glGetUniformLocation returns -1 for transformationMatrix:

int sum;

sum += transformationMatrix[0][0];

There is no compilation errors. The shader is binded and the file is loaded for sure. Positions from VBO works fine. It is only for uniforms.

Having Trouble Installing Eclipse on Mac OS

This is my first time with the macOS operating system so I could be making a common mistake easily, but I’ve watched multiple Youtube videos and read some articles and I haven’t found an answer yet on why my Eclipse IDE isn’t working. I’ve tried completely uninstalling Eclipse and re-downloading it and it still has the same error. The application installs correctly, but every time I try running the program it says “An error has occurred” and to check the .metadata/.log file. The problem is when I go to that directory nothing is created. I would appreciate any help from anyone who has experienced this issue before or knows how to fix it. I have both Java 9 for the JDK and JRE.

Images: Error Message (Blocked out my name) |
Shows no files were created for me to check

Thanks in advance for any help!

Swagger spec representation of blob

I am creating a swagger spec for a new endpoint that will be receiving a file as a binary data. How might you represent this in a swagger spec? I see object as a data type but that does not appear to be what I’m looking for. Has anyone done this in the past?

RocksDB Java get() got java.lang.NegativeArraySizeException

I’m running into a strange issue with RocksDB java API.
I’m trying to load some data from a text file into RocksDB with following code (I use merge method for read-and-update existing value):

while(read key, value as string from input file){
        try {
            byte[] resultBytes = db.get(key.getBytes());
            if (resultBytes == null || resultBytes.length == 0) {
                db.put(key.getBytes(), value.getBytes());
            } else {
                db.merge(key.getBytes(), resultBytes);
            }
        }catch(Exception e){
            throw new RuntimeException(e);
        }
}

Then I got this error:

Caused by: java.lang.NegativeArraySizeException
    at org.rocksdb.RocksDB.get(Native Method)
    at org.rocksdb.RocksDB.get(RocksDB.java:791)
    at 

Anyone know why this error happened?

Thanks in advance!

how to run my selenium test methods in parallel using testng

I am trying to run my automated tests(Selenium webdriver) in parallel using testng. this is the node which I am running:

java -Dwebdriver.gecko.driver=chromedriver.exe -jar selenium-server-standalone-3.4.0.jar -role node -hub http://localhost:4444/grid/register -browser browserName=chrome,maxInstances=2 -maxSession 2

this is my test class:

public class TestParallel {

Login login;

//@BeforeMethod(alwaysRun = true)
public SeleniumDriverCore testSetup() throws FileNotFoundException, IOException{
    SeleniumDriverCore driver = new SeleniumDriverCore("config/chromeDriverConfig");
    Properties config = new Properties();
    config.load(new FileInputStream("config/testConfig"));
    this.login = new Login(driver);
    driver.browser.open("https://test.test.xyz");

    driver.browser.maximize();
    driver.waits.waitForPageToLoad();
    return driver;
}

@Test(groups={"parallel"})
public void test_one() throws FileNotFoundException, IOException{
    SeleniumDriverCore driver=testSetup();
    testSetup();
    login.navigateToPage(Pages.LOGIN);
    login.assertion.verifyLoginPopupAndTitleDisplayed();
    testCleanup(driver);
}

@Test(groups={"parallel"})
public void test_two() throws FileNotFoundException, IOException{
    SeleniumDriverCore driver=testSetup();
    testSetup();
    login.navigateToPage(Pages.LOGIN);
    login.assertion.verifyLoginPopupAndTitleDisplayed();
    testCleanup(driver);
}

@Test(groups={"parallel"})
public void test_three() throws FileNotFoundException, IOException{
    SeleniumDriverCore driver=testSetup();
    testSetup();
    login.navigateToPage(Pages.LOGIN);
    login.assertion.verifyLoginPopupAndTitleDisplayed();
    testCleanup(driver);
}

@Test(groups={"parallel"})
public void test_four() throws FileNotFoundException, IOException{
    SeleniumDriverCore driver=testSetup();
    testSetup();
    login.navigateToPage(Pages.LOGIN);
    login.assertion.verifyLoginPopupAndTitleDisplayed();
    testCleanup(driver);
}


public void testCleanup(SeleniumDriverCore driver){
    driver.close();
    driver.quit();
}

}

and here is my xml:

<suite name="Ontega - All Tests Mobile" parallel="methods" thread-count="2">
    <test name="Ontega - All Tests Mobile">
        <groups>
            <run>
                <include name="parallel"/>
                <exclude name="open-defects"/>
            </run>
        </groups>
        <packages>
            <package name="tests.*"/>
        </packages>
    </test>
</suite>

when I run the XML, I expect to have my tests to be running on two browsers in two threads at a time, however when I run the XML I get two browser instances running at the first time and then they are incremented and 50% of the tests are failing, as you can see I am trying to instantiate the driver in each of my methods, although it’s not how my framework is working, but I am trying to get to the bottleneck of this issue.
Any help would be very appreciated
Thanks in advance

Hibernate Retrieve all possible foreign key objects if record is not associated with any

With a many-to-many relationship as shown below; how can I retrieve all the related objects for a record. And if the record is not associated with any, retrieve all the records from the associated table.

| Table 1  |      | Many to Many Table |     | Table 2 |
________           __________________        ___________
| 1    |          |         1, A       |     |   A     |
| 2    |          |         1, B       |     |   B     |  
| 3    |          |         2, C       |     |   C     |

In this example all tables just have an ID column and the many-to-many join table is just (table 1, table 2).

So the desired result is to get the list [A, B] when selecting the associated records in Table 2 from Table 1 where Table 1 = 1, then just [C] when selecting the set for id = 2 which is straightforward. The interesting part is that when selecting the associated records for table 3, I want to return all of the records [A,B,C] instead of an empty set.

I can’t just create the association for id = 3 for every record in table 2 because I would have to do it every time a record was inserted into table 2. I could do it in two transactions, basically if the returning set is null just select all from table 2 but I really would like to do it in one clean go.

The HQL for the first bit is easy select table_1.table_2 from table_1 where table_1.id = :id and then just pass in an ID and list the results.

The part I don’t quite know is then how to add into the query “If no results, select all from table 2”

How to reset DB field values to default while using Hibernate update?

I am very naive in using Hibernate. I have a table which have all fields as not null and default. String fields are having spaces(” “) as default and int fields are having 1 or 0 as default. Also there is 1 timestamp field which has a date as default.

Now while consumer can enter any values using my rest services. But if he sends nothing in the field I want to set DB field values to reset to default. I dont want to do hard code same default values in Java side before calling update. I want to have default values defined only in DB side.

I have tried dynamic-insert=”true” which helps me during create operation if consumer do not provide anything then I put null in fields in Java side which is not included in final query.

But this approach do not helps me during update since some fields have change and some are simply nothing sent by consumer. So I also tried dynamic-update=”true” with dynamic-insert=”true”. In case of db fields with values and consumer sent nothing for the field then it is considered as change and it makes upto final query which hibernate prepares. Therefore its not able to serve my purpose.

How can I get these fields reset to default values which DB has for these fields while consumer has sent nothing(empty or null)?

I am using DB2 and Hibernate. Thanks

javascript calculate total from dropdown and checkbox not updating to 0 when on another select box

I have a script that calculate total based on dropdown boxes and check boxes , I have main drop down menu with

<select id="type" name="menu">
<option value="">Service Needed</option>
<option value="kite">Car Wash & Detailing</option>
<option value="user">Mechanic visit</option>
<option value="elect">Electrican visit</option>
<option value="tyre">Tyre Service</option>
<option value="bat">Battery Service</option>
</select>

SUB MENU


 <select  id="type2" name="buyername" class="form-control input-lg form-el calculate" >
 <option data-price="0" value="">-- Select --</option>
 <option data-price="100" value="kite1">Car Wash exterior</option>
 <option data-price="150" value="kite1">Car Wash In & Out</option>
 <option data-price="1000" value="kite2">Full Detailing</option>
 </select>      

now when you select service like car wash & detailing then choose car wash exterior from sub menu the total price shown is 100, then after i click on another service like mechanic visit the price still on 100 , it should be 0 again as the price menu is deselected

here is the script

 <script type='text/javascript'>//<![CDATA[
 $(function(){
 $("select.calculate").on("change", calc);
 $("input[type=checkbox].calculate").on("click", calc);

 function calc() {
 var basePrice = 0;
 newPrice = basePrice;
// You need to loop over, not only the selected option, but also the checked checboxes
 $("select.calculate option:selected,input[type=checkbox].calculate:checked").each(function (idx, el) {
  newPrice += parseInt($(el).data('price'), 10);
});

newPrice = newPrice.toFixed(2);
$("#item-price").html(newPrice);
}
});
 </script>

any idea how to fix this.??

MySQL DB or JDBC driver not handling LocalDate.MAX

I am trying to run a query with a start date and end date as parameters, which may be null.

MySQL – the DB or the JDBC driver or in combination – cannot handle null values by which I mean, the SQL AND endDate <= null excludes every row.

So I am trying to use startDate >= LocalDate.MIN which works well for the “no start date”.

But endDate <= LocalDate.MAX doesn’t work to allow any date. This is the SQL template:

String strStmt = "SELECT d.forecastId, d.valueDate, d.value " +
        "FROM data d " +
        "WHERE d.forecastId = ? " +
        "AND valueDate >= ? " +
        "AND valueDate <= ? " +

and this is the variable allocation:

if (startDate == null) {
    statement.setObject(2, LocalDate.MIN);
} else {
    statement.setObject(2, startDate.toInstant().atZone(
            ZoneId.systemDefault()).toLocalDate());
}
if (endDate == null) {
    statement.setObject(3, LocalDate.MAX);
} else {
    statement.setObject(3, endDate.toInstant().atZone(
            ZoneId.systemDefault()).toLocalDate());
}
try (ResultSet rs = statement.executeQuery()) { 
...

and this is the SQL which it produces (via P6Spy):

SELECT valueDate FROM data d WHERE d.forecastId = 52010 
AND valueDate >= '-999999999-01-01' 
AND valueDate <= '+999999999-12-31'

This doesn’t work, I get no rows.

If I then change it to something less extreme:

if (endDate == null) {
    statement.setObject(3, LocalDate.parse("2019-01-01"));
...

I see the following in the P6Spy logging:

SELECT valueDate FROM data d WHERE d.forecastId = 52010 
AND valueDate >= '-999999999-01-01' 
AND valueDate <= '2019-01-01'

and the query works fine, except of course at some point in the future.

Is this some sort of overflow in MySQL? Should I use LocalDate.MAX differently or what can I use instead of LocalDate.MAX?

I don’t wish to revert to

    statement.setDate(3, new java.sql.Date(Long.MAX_VALUE); 

which produces the following:

AND valueDate <= '17-Aug-94'

which doesn’t work either – maybe a Y2K or Year 2038 bug? P6Spy is not helping by displaying it with its own unhelpful format.

Another restriction is that I can’t swop out the JDBC driver – currently mysql-connector-java:6.0.4 – because I’m using the fab MariaDb4j as my test database and it has the JDBC driver hard-coded (not so fab).