This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CartRepository { | |
private static Properties dbConnProps; | |
public static List<Cart> getCartItems(String userId) throws SQLException { | |
List<Cart> records = new ArrayList<>(); | |
Connection connection = DriverManager.getConnection(dbConnProps.getProperty("url"), | |
dbConnProps.getProperty("user"), | |
dbConnProps.getProperty("password")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
config.json | |
{ | |
"stats_key1": { | |
"name": "Stats Key1", | |
"compute": { | |
"function": "calc_stats_key1", | |
"args": {"name": "test1", "age": 1} | |
} | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wget http://downloads.sourceforge.net/project/cyclops-group/jmxterm/0.2/jmxterm-0.2-uber.jar | |
a@a:~$ java -jar jmxterm-0.2-uber.jar | |
Welcome to JMX terminal. Type "help" for available commands. | |
?$ open localhost:8076 | |
Connection to localhost:8076 is opened | |
>$ bean java.lang:type=Memory | |
bean is set to java.lang:type=Memory | |
>$ run gc | |
calling operation gc of mbean java.lang:type=Memory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Maps the {@link ResultSet} object from SQL query result to ORM Entity class. | |
* <p> | |
* For reflection cost optimization it uses the entity class fields list from | |
* {@link orm.cache.EntityFieldsCache} cache object. | |
* <p> | |
* It maps SQL data types to the Java data types as defined in the {@link ColumnField} annotations. | |
*/ | |
public final class ResultSetToEntityMapper { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP TABLE IF EXISTS issue_metrics_table; | |
CREATE TABLE IF NOT EXISTS issue_metrics_table ( | |
domain TEXT NOT NULL, | |
issue_id TEXT NOT NULL, | |
created_at BIGINT NOT NULL, | |
inbound_count BIGINT, | |
outbound_count BIGINT, | |
csat INT | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Data accessor class to access paginated entity objects {@link T}. | |
* These entity objects are mapped from {@link ResultSet} objects obtained from querying the | |
* table for the specified objects {@link T} for which {@link DataAccessor} class is defined | |
* <p> | |
* Created by abhishek on 21/06/19. | |
*/ | |
public class DataAccessor<T> { | |
private final Class<T> entityClass; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DataAccessorTest { | |
@Test | |
public void issueMetricsPaginateTest() throws Exception { | |
DataAccessor<IssueMetrics> da = new DataAccessor<IssueMetrics>(IssueMetrics.class) | |
.withFilter(new String[]{"domain", "eq"}, "hscustomer") | |
.withFilter(new String[]{"created_at", "gte"}, 1001) | |
.withFilter(new String[]{"created_at", "lt"}, 1003) | |
.build(); | |
Assert.assertNotNull(da.getGeneratedQuery()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* ORM Entity class for 'agent_metrics_table' table. | |
* | |
* @ColumnField annotation injects the table schema information on each entity fields like | |
* i) the column name, | |
* ii) column alias to be used for aggregate function queries, | |
* iii) data type to which the table column data is to casted during data mapping to entity class | |
* iv) if this field corresponds to PK column and its position in the PK composite column and | |
* v) if this column is to be used as group-by field for an aggregated query | |
* vi) the aggregate function/UDF to applied on the column during query |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* ORM Entity class for 'issue_metrics_table' table. | |
*/ | |
@Table(name = "issue_metrics_table") | |
public class IssueMetrics { | |
@ColumnField(type = ColumnField.FieldType.STRING, | |
name = "domain", | |
pk = true, | |
pkPosition = 0) | |
public String domain; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Retention(RetentionPolicy.RUNTIME) | |
@Target(ElementType.TYPE) | |
public @interface Table { | |
/** | |
* name of the table corresponding to this entity | |
*/ | |
String name() default ""; | |
} |
NewerOlder