hibernate unable to load extended class entity column names if parent class uses lombok annotation

Hi I’m using lombok api with entity class having @Data annotation which extends audit class (common columns) which is simple abstract class with @MappedSuperclass and @Data annotation. But when hibernate-jpa loads it is not picking up the column names but instead its picking up actual member variable names.

@Table(name = "TEST_TYPES", schema = "TESTER")
@EqualsAndHashCode(callSuper = false, of = {"id"})
public class TestEntity extends AuditEntity {
    @Column(name = "TYPE_ID")
    private Short id;

    @Column(name = "NAME")
    private String name;    

public abstract class AuditEntity implements Serializable {
    private static final long serialVersionUID = 3487394229267512541L;

    @Column(name = "CREATED_BY", length = 40)
    private String createdBy;

    @Column(name = "CREATED_DATE", length = 7)
    private Date createdDate;    

Hibernate throwing this error..
Caused by: java.sql.SQLSyntaxErrorException: ORA-00904: “TESTPROJJU0_”.”CREATEDBY”: invalid identifier

hibernate should pick the column name ie “CREATED_BY” but it is picking up “createdby”

I appreciate any suggestion/help.

Get the values which are unique in a given list [duplicate]

This question already has an answer here:

Is there a simple way to get a list of the unique values of a given list in java?

For example :

List<Integer> a = new ArrayList(Arrays.asList(1,2,2,2,3,3,4,5));
List<Integer> b = getUniqueValues(a);

Give the output :


I would like to know if its exists a simple way to have this getUniqueValues() function in java.

All that I find on internet are ways to return the list of distinct elements (in my example, the ouput would be [1,2,3,4,5]) : that is not what I want.

Java validating user integer input

I have written code which

1) Continously asking user to select number and check if input is integer

private static int readInputInt(String error) {
    Scanner s = new Scanner(System.in);
    while (!s.hasNextInt()) {
    int result = s.nextInt();
    return result;

2) Continously asking user to select number within range and showing only errors, program do not show message to ask user to provide input once again.

private static int readInputInt(String error, int max) {
    Scanner s = new Scanner(System.in);
    int result;
    do {
        while(!s.hasNextInt()) {
            //show error if it is not integer and get input once again
        result = s.nextInt();
        // if result is integer check if it is bigger than max
        if(result > max) {

    }while(result > max);

and I was wondering if there is any simpler way to do this because I spent too much time for this and I think it is rubbish way of coding.

Firsly I tought that below code will work:

private static int readInputInt(String error, int max) {
    Scanner s = new Scanner(System.in);
    while (!s.hasNextInt() && (s.nextInt < max)) {
    int result = s.nextInt();
    return result;

but it don’t work. For any help thank you!

AMQ Consumers choose which queue to process

Given the following scenario:

I have a system that creates, updates and deletes records. For each of these actions I need to do something (lets say write the events to a log as a silly example) however I need to process these events for each record in order – Meaning I can’t log the delete before I have done the create, or any of the previous updates. I also can’t log the update before I have logged the create.

I am investigating Queues in order to preserve sequence. However I don’t really want RecordID_2 to be held up behind RecordID_14 The records do not need to be processed in sequence as much as the actions on each record have to. Hence I don’t think I can/should use one queue.

As I don’t have hundreds of RecordID_XX active at the same time, I was thinking of having a queue for each RecordID_XX so if several updates can in for that one RecordID each event for that record would be added to that same queue and be processed in order (I.e. Create first, Update_1 after Create is complete, Update_2 is processed after Update_1 is complete etc), however if additional events for a different record came in they would be added to their own queue. If the queue is empty for a period of time it simply gets deleted. I realize that this may result in a queue getting one message and then being deleted as there were no updates before the idle timeout expired. (This does not seem at all efficient)

Based on Andres T Finnell’s excellent answer to this question.

I was thinking of doing the following

Producer (Web Service) -> Queue_Original <- Dispatcher  -> RecordID_14 
                                                        -> RecordID_2 
                                                        -> RecordID_8
                                                        -> RecordID_15

Some of the “logging” may take long. So I want to be able to have a few consumers listening for these queues.

Lets say I have Consumer_1 and Consumer_2 (I may want to add Consumer_3 later to assist with growing load)

What I would like is Consumer_1 to do a getDistinations()
where the broker will return [RecordID_14, RecordID_2, RecordID_8, RecordID_15]

Is it possible for Consumer_1 to iterate through the list of queues returned from the broker looking for the first available queue that does not have a Consumer_X connected to it and begin processing the 1st message on this queue? And then each subsequent Consumer to do the same until it finds the next queue without a Consumer connected to it?

Am I going down the wrong path completely? Is there a better approach to handling this scenario?

Configuring Payara/GlassFish JMS connection factory for remote connection factory

I am working on trying to understand how to properly configure Payara/GlassFish messaging so that messages are sent and received from a remote Open MQ server.

From the Payara/GlassFish admin console, I can go to Configurations > server-config > “Java Messaging Service” and from there I can setup a new “JMS Host” which points to the remote Open MQ server. I then configure the “JMS Service Type” to REMOTE and do a few other things to get Payara/GlassFish to communicate with the Open MQ borker instance on the remote host. I understand this.

Now when setting up a connection factory, I go to Resources > “JMS Resources” > “Connection Factories” When setting up the connection factory, what I don’t understand is the need for the “AddressList” property if using a remote JMS broker. If I do the 1st step and update the “Java Messaging Service” to REMOTE and to connect to a remote broker, is the “AddressList” property still needed? If I do need “AddressList”, then what’s the point of the “Java Messaging Service” configuration?

how to creat dynamic datasource bean at runtime and connect to different databased using mybastis at runtime

i have requirement to connect to different data-sources in spring boot application. database connection will be entered in ui for different consumers.
it should connect to all consumer databases and fetch records dynamically as requested . I tried using AbstractRoutingDataSource but it requires pre-defined data-source beans to route different database calls

please can anybody tell me how to link dynamically created datasource beans to AbstractRoutingDataSource or is there any other way for dynamically creating data source with datasource routing as per consumer.

Storing the subtracted/added value in ArrayList

I have a class with an ObservableList object which display all objects in the “items” ArrayList. When the “sell/Restock” button is clicked a popup window shows up displaying the selected record in the table, an input field which updates the the stockLvl value from the object inside the “items” ArrayList.

// Sell/Restock Button Listener
private void sellRestockButtonClicked()
        ObservableList<Product> productSelected = table.getSelectionModel().getSelectedItems();
        sellRestock transaction = new sellRestock(productSelected, items);
    } catch (NullPointerException e) {
        Alert alert = new Alert(Alert.AlertType.ERROR);
        alert.setHeaderText("No item selected");
        alert.setContentText("Select an item to sell/restock.");


The code in the “sellRestock” class which updates that value is inside an actionPerfomed method:

private void submitBtnClicked(ObservableList<Product> selectionIn, ArrayList<Product> itemsIn)
    try {
        int reStockSellOrder = Integer.parseInt(quantity.getText());
        for(int i = 0; i < itemsIn.size(); i++)
            // If item found in array, sell or restock
            if (itemsIn.get(i) == selectionIn.get(0))

    } catch (NumberFormatException e) {
        Alert alert = new Alert(Alert.AlertType.ERROR);
        alert.setHeaderText("Unable to proceed with the transaction !");
        alert.setContentText("The quantity input field takes only integer values.");


the sell or reStock method subtracts or adds the right amount, but the value is not saved inside the “items” arrayList, so when I try to update the ObservabeList (with the following Line -> table.setItems(getProduct());), nothing actually changes. Does anyone have a solution to my problem, I’d greatly appreciate it ?

Interfaces as parameters (Restrictions)

I came across an AP CSA question which had me puzzled for a while. It was basically an incomplete method that looked like this:

public static void methodMan(Comparable c) {…..}

The question first asked if it was valid to use the comparable interface in the parameter listing, then it asked if there were any restrictions on the comparable object. I was stuck between the choices that said either the object c that is being passed needs to be casted or initialized as a comparable or the object c could be any object that implements the comparable interface. Which one is it, and if it isn’t either, what would be a restriction on the object c?

How to resolve flyway error where flyway migration does not pick up script due to missing suffix

Flyway via Java

I created a new sql file to be migrate via flyway.
I committed in my code. When I went to kick off the flyway migration, I noticed flyway was not picking up the file.

The only difference between this file and others was it was missing suffix “.sql” at the end of it.

Now when I try to create a new file with same create statements, I recieve an assertion error.

Any idea how I can fix this?